The records are written to be logical place as determined from the value of the record key. The INVALID KEY condition occurs in the cases shown below:
(i) When a try is made to write a record beyond the externally defined boundaries of the file.
(ii) Whenever the file is opened in the OUTPUT mode and the value of the record key is not bigger than the value of the record key for the earlier record written.
(iii) When the value of the record key is equivalent to the record key of a record key already present in the file.