The ENDFILE statement writes an endfile record as the next record of an external file connected for sequential access. This record becomes the last record in the file.
An ENDFILE statement for a file connected for stream access causes the terminal point to become the current file position. File storage units before the current position are considered written, and can be read. You can write additional data to the file by using subsequent stream output statements.
If the unit is not connected, an implicit OPEN specifying sequential access is performed to a default file named fort.n, where n is the value of u with leading zeros removed.
If two ENDFILE statements are executed for the same file without an intervening REWIND or BACKSPACE statement, the second ENDFILE statement is ignored.
After execution of an ENDFILE statement for a file connected for sequential access, a BACKSPACE or REWIND statement must be used to reposition the file prior to execution of any data transfer input/output statement.
If the ERR= and IOSTAT= specifiers are set and an error is encountered, transfer is made to the statement specified by the ERR= specifier and a positive integer value is assigned to ios.
If IOSTAT= and ERR= are not specified,
ENDFILE 12 ENDFILE (IOSTAT=IOSS,UNIT=11)