Changed fileinput to io.open when opening files directly. This was causing differences in processing the file