Several of the I/O statements can take an optional AT END phrase and NOT AT END phrase. Both of these phrases are followed by a statement that is conditionally executed, depending on the result of the I/O statement. The discussion of each I/O statement that can take the AT END phrase specifies the conditions that cause the at-end condition to be in effect. If the at-end condition is in effect, one of the following happens:
If the NOT AT END phrase is present, it is executed if the I/O statement is successful. Note that it is possible to execute neither the AT END nor NOT AT END phrases if an I/O error occurs that does not set the at-end condition. In this case, the AT END phrase is not executed (because the at-end condition is not in effect) and the NOT AT END phrase does not execute (because the I/O statement is not successful).
All of the preceding comments about the AT END and NOT AT END phrases also apply to the INVALID KEY and NOT INVALID KEY phrases (except that the invalid-key condition is tested instead of the at-end condition).