with-open-file uses open to create a file stream
to file named by filespec.
Filespec is the name of the file to be opened.
Options are used as keyword arguments to open.
The stream object to which the stream variable
is bound has dynamic extent;
its extent ends when the form is exited.
with-open-file evaluates the forms as an implicit progn
with stream bound to
the value returned by open.
When control leaves the body, either normally or abnormally (such as by
use of throw), the file is automatically closed. If a new
output file is being written, and control leaves abnormally, the file is
aborted and the file system is left, so far as possible, as if the file
had never been opened.
It is possible by the use of :if-exists nil
or :if-does-not-exist nil for
stream to be bound to nil.
Users of :if-does-not-exist nil should check for a valid stream.
The consequences are undefined if an attempt is made to assign the
stream variable. The compiler may choose to issue a
warning if such an attempt is detected.