def scanner(name, function): file = open(name, 'r') # create file for line in file.readlines(): function(line) # call function file.close()