IDENTIFICATION DIVISION.
PROGRAM-ID. PLUS5NUMBERS.

ENVIRONMENT DIVISION.
      INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT IN-FILE ASSIGN TO "numbers.txt"
           ACCESS MODE IS SEQUENTIAL
           ORGANIZATION IS LINE SEQUENTIAL.
           SELECT OUT-FILE ASSIGN TO "newNumbers.txt"
           ACCESS MODE IS SEQUENTIAL
           ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.

FILE SECTION.

FD IN-FILE.
01 IN-RECORD.
      05 ORIGINAL-NUMBER   PIC 9(5).

FD OUT-FILE.
01 OUT-RECORD.
      05 OUT-NUMBER        PIC 9(5).

WORKING-STORAGE SECTION.
       77 RESULT        PIC 9(5).
       77 NE-RESULT     PIC ZZZZ9.
       01 FS            PIC 99.

01 SWITCHES.
      05 EOF-SWITCH        PIC X VALUE "N".

01 COUNTERS.
      05 REC-COUNTER       PIC 9(3) VALUE ZERO.


PROCEDURE DIVISION.

000-MAIN.

           PERFORM 100-INITIALIZE.
           PERFORM 200-PROCESS-RECORDS
           UNTIL EOF-SWITCH = "Y".
           PERFORM 300-TERMINATE.

100-INITIALIZE.

           OPEN INPUT IN-FILE.
           OPEN EXTEND OUT-FILE.
           READ IN-FILE
               AT END
                   MOVE "Y" to EOF-SWITCH
           END-READ.

200-PROCESS-RECORDS.
           COMPUTE RESULT = ORIGINAL-NUMBER + 5.

           MOVE RESULT to NE-RESULT.

           MOVE NE-RESULT TO OUT-NUMBER.
           WRITE OUT-RECORD.

           DISPLAY NE-RESULT.

           READ IN-FILE
               AT END
                   MOVE "Y" to EOF-SWITCH
           END-READ.


300-TERMINATE.

           CLOSE IN-FILE.
           CLOSE OUT-FILE.
           STOP RUN.
