I want to append a newline to my string every time I call
file.write(). What's the easiest way to do this in Python?
You can do this in two ways:
f.write("text to write\n")
or, depending on your Python version (2 or 3):
print >>f, "text to write" # Python 2.x print("text to write", file=f) # Python 3.x