If you are showing a string, as in the Jay example, you do not need to use newline- MzScheme strings include normal C screens, so you can just do
(with-output-to-file "foo.txt"
(lambda ()
(display "hello world\n")))
, with-... , Jay-, - MzScheme , , .