[python] How to write to a file without overwriting current contents?