On this page:
read-file
write-file

2.1 Batch Input/Output: "batch-io.ss"

Matthias Felleisen

 (require 2htdp/batch-io)

The batch-io teachpack introduces two functions: read-file and write-file. It facilitates the reading and writing of entire files in one batch.

(read-file f)  string?
  f : (and/c string? file-exists?)
reads the content of file f, located in the samd folder (directory) as the program, and produces it as a string. If f doesn’t exist, the function signals an error.

(write-file f cntnt)  boolean?
  f : string?
  cntnt : string?
turns cntnt into the content of file f, located in the same folder (directory) as the program. If the file exists when the function is called, the function produces true; otherwise it produces false.