in reply to utf8 writing

Can you copy and paste a small part of the original text and the matching sample file contents into a code block in your node so we can see what the bad character is and where it cane from?

Are you sure you are using a UTF8 aware viewer to examine the file?

True laziness is hard work