Text files: iterating over the lines in the file
f = open("filename") while 1: line = f.readline() if not line: break #process(line) f.close()