It would be worth checking on the error code you got. There is a table in the Cobol manuals. There is a discrepency between the type of file you are using, the type of open you are using, and the type of write that you are doing.
If you have a sequential file (DSORG=PS) then read input file, write seperate output file as has been suggested to you already. If you have a VSAM file, your requirement may be to update it in place. Check exactly how you are achieving the rewriting against what is in the manual - and remember to back-up the file before your job runs, and to restore the file before your job re-runs in the event of failure/error.