The ENDFILE statement writes an end-of-file record to the specified unit. It takes one of the following forms:
ENDFILE ([UNIT=]u [,ERR=s] [,IOSTAT=ios]) ENDFILE u
If the unit specified in the ENDFILE statement is not open, the default file is opened for unformatted output.
An end-of-file record can be written only to files opened for sequential access having either relative or sequential organization. Relative files must have formatted, fixed-length records. Files with sequential orgainization must be accessed as formatted or unformatted-segmented files.
An ENDFILE statement must not be issued for a file that is open for direct or keyed access.
An end-of-file record written to a file on magnetic tape is not the same as a tape mark.
End-of-file records should not be written in files that are read
by programs written in a language other than Fortran, because
other languages do not support the embedded end-of-file concept.
In the following example, an end-of-file record is written to logical unit 2:
ENDFILE 2