Python: Write to next empty line
<p>I'm trying to write the output of something that is being done over three big iterations and each time I'm opening and closing the outfile. Counters get reset and things like this after the iterations and I'm a massive newb and would struggle to work around this with the shoddy code I've written. So even if it's slower I'd like change the way it is being output.</p>

<p>Currently for the output it's just rewriting over the first line so I have only the output of the last run of the program. (tau, output are variables given values in the iterations above in the code)</p>

<pre><code>with open(fileName + '.autocorrelate', "w") as outfile:
    outfile.writelines('{0}     {1}{2}'.format(tau, output, '\n'))
</code></pre>

<p>I was wondering if there are any quick ways to get python to check for the first empty line when it opens a file and write the new line there?</p>
