This section describes procedures used to open ports to files. File ports are automatically closed if and when they are reclaimed by the garbage collector. Before opening a file for input or output, by whatever method, the filename argument is converted to canonical form by calling the procedure merge-pathnames with filename as its sole argument. Thus, filename can be either a string or a pathname, and it is merged with the current pathname defaults to produce the pathname that is then opened. Any file can be opened in one of two modes, normal or binary .
Normal mode is for accessing text files, and binary mode is for accessing other files.
Some operating systems, e.g. unix, do not distinguish these modes. In binary mode, ms-dos ports do not perform newline translation. Unless otherwise mentioned, the procedures in this section open files in normal mode. Takes a filename referring to an output file to be created and returns an output port capable of writing characters to a new file by that name. If the file does not exist, append mode creates the file and writes to it in the normal way.