removing blank lines after text on a file python
<p>I have a python program with generates a file.<br>
I want to remove the lines with spaces at the end<br>
my program outputs a file like this:</p>

<pre><code>&gt; cat output
some text

some text



&gt;
</code></pre>

<p>The output that I need is:</p>

<pre><code>&gt; cat output
some text

some text
&gt;
</code></pre>

<p>Thanks in advance</p>

<p>How about this?</p>

<pre><code>name = "filename"
f = open(name, 'r')
out = [];
for line in f:
  if line.trim() != "":
    out.append(line);
f.close()
f = open(name,'w')
for line in out:
  f.write(line)
</code></pre>

python file