The issue is the difference between how the debugger will present the data vs how the data will actually be rendered when dumped directly into a file. Tim’s solution is essentially recreating the output the way the debugger presents it.
The reason for this is that you may have wanted to put semicolons/tabs/commas in between each string instead of newlines. The debugger shows you the output in a legible way by default when it can, but when using it, that does not happens so you can choose how you want the output to look.
This is definitely not intuitive since you don’t expect there to be a difference between the debugger and actual use.