unwordwrap a file

I hate when I get a text file that I want to load onto my Palm device, and I find it’s already full of newlines. When I use txt2pdbdoc the pre-wrapped lines end up making the display of the file a headache to use. It’s like old emails you used to receive:

Hi, my name is Owen
Williams
and for some reason
my
software is a little narrower
than
yours so everything
looks
like crap.

Well here’s a python script that will remove newlines from any text file. It’s really quick and stupid. (See extended entry)

————unwordwrap.py—————-

#!/usr/bin/python
import sys
if len(sys.argv)<2:    print "Need a file to unwrap"    sys.exit() f=open(sys.argv[1], 'r') while 1==1:    try:       line=f.readline()       if line=="\n":          print "\n"       else:          print line[0:len(line)-1],       if len(line)==0:          break    except ValueError:       break

—————EOF———————–