dataout = file("sample.txt", "w") dataout.write("Some text\n") dataout.write("...that is written to a file\n") dataout.close()