Trying to get rid of illegal character at end of file