title: Python script to remove multiple blank lines between paragraphs and end of file
body: <p>I wrote a python script to capture the data I want but
  I have a resulting text file that contains multiple paragraphs but each paragraph is separated by varying blank lines - anywhere from 2 to 8.</p>
  
  <p>My file also has multiple blank lines at the end of the file.</p>
  
  <p>I would like Python to leave no more than 2 blank lines between paragraphs and and no blank lines at the end of the text file. </p>
  
  <p>I have experimented with a loop and line.strip, replace etc but I clearly have little idea how to put this together.</p>
  
  <p>examples of what I have been using so far</p>
  
  <pre><code>wf = open(FILE,"w+")
  for line in wf:
           newline = line.strip('^\r\n')
           wf.write(newline)
           wf.write('\n')
  </code></pre>