The ENDFILE statement writes an end-of-file record to a sequential file and positions the file after this record (the terminal point).
An ENDFILE statement takes one of the following forms:
ENDFILE ([UNIT=]io-unit [,ERR=label] [,IOSTAT=i-var]) ENDFILE io-unit
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.
End-of-file records should not be written in files that are
read by programs written in a language other than Fortran.
The following statement writes an end-of-file record to I/O unit 2:
ENDFILE 2
Suppose the following statement is specified:
ENDFILE (UNIT=9, IOSTAT=IOS, ERR=10)
An end-of-file record is written to the file connected to unit 9. If an error occurs, control is transferred to the statement labeled 10, and a positive integer is stored in variable IOS.