myfile = open('myfile', 'w') # open for output (creates) myfile.write('hello text file\n') # write a line of text myfile.close()