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 with sequential organization that are accessed as formatted-sequential or unformatted-segmented sequential files. For example, the following statement writes an end-of-file record to the logical unit 2:
ENDFILE 2
An ENDFILE statement must not be issued for a file that is open for
direct access. End-of-file records should not be written in files
that are read by programs written in a language other than Fortran.