Closes an open file
Supported Platforms: Windows and Mac OS
(close file-desc)
Type: File
A file descriptor obtained from the open function.
Type: Nil
nil if file-desc is valid; otherwise results in an error message.
After a close, the file descriptor is unchanged but is no longer valid. Data added to an open file is not actually written until the file is closed.
The following code counts the number of lines in the file somefile.txt and sets the variable ct equal to that number:
(setq fil "SOMEFILE.TXT") (setq x (open fil "r") ct 0) (while (read-line x) (setq ct (1+ ct)) ) (close x)