f = open('somefile.txt', 'w') print >> f, 'This is the first line' print >> f, 'This is the second line' print >> f, 'This is the third line' f.close()