title: Regular expression to remove line breaks
body: <p>I am a complete newbie to Python, and I'm stuck with a regex problem. I'm trying to remove the line break character at the end of each line in a text file, but only if it follows a lowercase letter, i.e. <code>[a-z]</code>. If the end of the line ends in a lower case letter, I want to replace the line break/newline character with a space.</p>
  
  <p>This is what I've got so far:</p>
  
  <pre><code>import re
  import sys
  
  textout = open("output.txt","w")
  textblock = open(sys.argv[1]).read()
  textout.write(re.sub("[a-z]\z","[a-z] ", textblock, re.MULTILINE) )
  textout.close()
  </code></pre>