Script to fix broken lines in a .txt file?

Posted by Gravitas on Stack Overflow See other posts from Stack Overflow or by Gravitas
Published on 2010-06-09T14:48:11Z Indexed on 2010/06/09 14:52 UTC
Read the original article Hit count: 229

Filed under:

Hi,

I'd love like to read books properly on my Kindle.

To achieve my dream, I need a script to fix broken lines in a txt file.

For example, if the txt file has this line:

He watched Kahlan as she walked with her shoulders slumped
down.

... then it should fix it by deleting the newline before the word "down":

He watched Kahlan as she walked with her shoulders slumped down.

So, fellow programmers, whats (a) the easiest way to do this and (b) the best language?

p.s. The solution will involve searching for a lowercase letter in column 1, and deleting the newline before it to stitch the lines together. There are 1.2 million occurrences of this "rogue line break" in the novel I am trying to fix.

© Stack Overflow or respective owner

Related posts about perl