If an error occurs when a record is being read, an attempt is made to obtain the record by rereading the error record several times. If the error record is unreadable and error recovery is not requested, SORT terminates. If error recovery is requested and the data has been duplicated, an attempt is made to read the duplicate copy. If the error record was written by the merge phase and no duplicate copy exists, SORT attempts to re-create the string of information containing the error record. Before backtracking to the previous merge, SORT writes and reads a test record in the error record location. If the test is unsuccessful, SORT marks as bad disk the row of the disk containing the error record location. After testing and possibly marking the affected areas of the disk, SORT backtracks to the desired point for restarting the merge phase. At most, one row of the disk is marked as bad disk for each occurrence of an input error for the work file.