Fix error where \r\n was causing extra empty lines to be written to csv