Python: Writing to a File
<p>I've been having trouble with this for a while. How do I open a file in python and continue writing to it but not overwriting what I had written before?</p>

<p>For instance:</p>

<p>The code below will write 'output is OK'.
Then the next few lines will overwrite it and it will just be 'DONE'</p>

<p>But I want both
'output is OK'
'DONE'
in the file</p>

<pre><code>f = open('out.log', 'w+')
f.write('output is ')
# some work
s = 'OK.'
f.write(s)
f.write('\n')
f.flush()
f.close()
# some other work
f = open('out.log', 'w+')
f.write('done\n')
f.flush()
f.close()
</code></pre>

<p>I want to be able to freely open and write to it in intervals. Close it. Then repeat the process over and over.</p>

<p>Thanks for any help :D</p>
