Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null.
Just extend the row to the length of the header:
for line_num, row in enumerate(reader): while len(row) < len(header): row.append('') ...