converting file from .txt to .csv doesn't write last column of data,writer.writerows(row.split() for row in infile if row.strip())