I doubt that your problem is with C++, per se. Octal 012 is a newline. I'm not surprised
to find one at the end. I suggest that your problem is in the handling. You don't say
much about that (system, OS, mechanism being used to make the transfer, or write the
file). You would have more luck interpreting the contents of your string if you looked at
it in hexadecimal format. Those '.'s could be anything. If there's a Windows stream
involved, and it's in default text mode, 0x1a will behave as an end-of-file indicator.
Nice job blowing the width to hell just to preserve '.'s that aren't readable, anyway

.