#coding=utf-8 f=open('text.txt','w') f.write('foo\n') f.write('bar\n') f.close() f=open('test.txt','r') for line in f: print line.rstrip()