file = open('test.txt') while 1: line = file.readline() # read line by line if not line: break print line, file.close()