in reply to printing text to a file in binary

Perhaps you have the text in a list of lines without linebreaks, and then print them without inserting linebreaks? There are so many things that can go wrong, and your description is so vague, that all of the wildly differing suggestions posted here might be applicable.

--
Morbo: "Windmills do not work that way!"