I am very new to Python. I know that this has already been asked, and I apologise, but the difference in this new situation is that spaces between strings are not equal. I
You can use csv:
import csv with open(ur_infile) as fin, open(ur_outfile, 'w') as fout: o=csv.writer(fout) for line in fin: o.writerow(line.split())