Write to file, append to file
# http://www.jonasjohn.de/snippets/python/python-write-to-file.htm
filename = "test.txt"
print "Writing to file: %s" % filename
file = open(filename, 'w') # write permission, overwrite existing contents
file.write("line 1\nThis is the new content of test.txt :-)\n")
file.close()
file = open(filename, 'a') # write and append
file.write("line 3 another separate instance\n\n")
file.close()