Writing to file with unwanted empty lines
<p>I have a piece of code that's removing some unwanted lines from a text file and writing the results to a new one:</p>

<pre><code>f = open('messyParamsList.txt')
g = open('cleanerParamsList.txt','w')
for line in f:
    if not line.startswith('W'):
        g.write('%s\n' % line)
</code></pre>

<p>The original file is single-spaced, but the new file has an empty line between each line of text. How can I lose the empty lines?</p>
