#!/usr/bin/python

import sys
import re

for fileName in sys.argv[1:]:
    f = open(fileName, 'r+')
    fileString = f.read()

    fileString = re.sub(r'[ ]+\n', r'\n', fileString)
    fileString = re.sub(r'\r', r'', fileString)
    f.seek(0)
    f.write(fileString)
    f.truncate(len(fileString))
