new.write('\n'.join(keep)).rstrip('\n') (or .lstrip if in beginning) instead of lines 18-23 ?
pyTony
pyMod
6,306 posts since Apr 2010
Reputation Points: 879
Solved Threads: 986
Skill Endorsements: 26
Sorry should be:
new.write('\n'.join(keep).rstrip('\n')) (or .lstrip if in beginning) instead of lines 18-23 ?
pyTony
pyMod
6,306 posts since Apr 2010
Reputation Points: 879
Solved Threads: 986
Skill Endorsements: 26
Test for length after you strip the line, and note that "new" is already used by Python.
for line in keep:
if len(line.strip()):
new_fp.write(line)
woooee
Posting Maven
2,706 posts since Dec 2006
Reputation Points: 827
Solved Threads: 779
Skill Endorsements: 9