COBOL Runtime Error Code – 158 Attempt to REWRITE to a line-sequential

In this post, you’ll learn about the COBOL runtime Error Code 158 and the reason why you are receiving it

COBOL Error Code :

158

Reason for this Error in COBOL

Attempt to REWRITE to a line-sequential file (Recoverable) -You have used the REWRITE statement in conjunction with a file whose organization is line sequential. The REWRITE statement cannot be used with line sequential files. -Close the file in error before executing a STOP RUN statement to ensure that you do not lose any data from it. Recode your program to make the organization of the file to which you want to do a REWRITE either sequential, indexed sequential, or relative.