How to print a new line in a file in plt schema?

I need to have a new line every time I write a file in the plt schema. I wonder if there is a special procedure that allows me to do this.

+5
source share
2 answers

newline may take an optional port argument on which it produces a new line.

(define myport (open-output-file "greeting.txt"))
(display "hello world" myport)
(newline myport)
+8
source

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 , , .

+10

All Articles