If I use a test file like this
When I was young, I did frequent
Scholar and sage, and heard much argument
About it and about...
But always came I out
By the same door as in I went.
prepared with CRLF line endings, and run it through the same textbook program as yesterday, I get identical output:
$ cksum Sample-ascii*
977717508 155 Sample-ascii2.txt
977717508 155 Sample-ascii.txt
$ xxd Sample-ascii2.txt
00000000: 5768 656e 2049 2077 6173 2079 6f75 6e67 When I was young
00000010: 2c20 4920 6469 6420 6672 6571 7565 6e74 , I did frequent
00000020: 0d0a 5363 686f 6c61 7220 616e 6420 7361 ..Scholar and sa
00000030: 6765 2c20 616e 6420 6865 6172 6420 6d75 ge, and heard mu
00000040: 6368 2061 7267 756d 656e 740d 0a41 626f ch argument..Abo
00000050: 7574 2069 7420 616e 6420 6162 6f75 742e ut it and about.
00000060: 2e2e 0d0a 4275 7420 616c 7761 7973 2063 ....But always c
00000070: 616d 6520 4920 6f75 740d 0a42 7920 7468 ame I out..By th
00000080: 6520 7361 6d65 2064 6f6f 7220 6173 2069 e same door as i
00000090: 6e20 4920 7765 6e74 2e0d 0a n I went...
If you compare that with yesterday's output, you will see that if the test file is UTF-16 the EOLs don't get deleted by ReadLn():
00000020: 6200 7200 6500 0d0a 000d 0a00 4300 6800 b.r.e.......C.h.
------------------------------^^^^^^^^^
That's the first problem. The second problem is that WriteLn() is emitting 8-bit CRLF rather than 16-bit:
00000020: 6200 7200 6500 0d0a 000d 0a00 4300 6800 b.r.e.......C.h.
-------------------------^^^^
The potential third problem is that you're relying on a dialog(ue) box to render 16-bit Unicode properly, I think the easiest thing would be to set a watchpoint on your buffer variable and then using the Properties dialogue to select Memory Dump. An alternative would be to explicitly iterate over the string dumping its content to the OS-level console, DO NOT rely on the console output window (also under View -> Debug Windows) for that since the hex+ASCII display there is too much at the mercy of the underlying debugger.
So you've potentially got three problems. Since you're consistently refused to post a concise example of a complete program to demonstrate what's going on, that's about all that can be said. Oh, and you do need to bear in mind that the third problem (GUI display) will be OS and widget set specific even if the other two (file handling) appear not to be.
MarkMLl