trying to remove weird characters at the end of the document