import re
import sys
with open(sys.argv[1]) as ifp:
    with open('output.txt', 'w') as ofp:
        for line in ifp:
            ofp.write(re.sub('(?m)([a-z])[\r\n]+$', '\\1 ', line))
Regular expression to remove line breaks