1  filename_var   PIC X(n) VALUE `c:\rb.txt`.
       1  bytes_num      PIC 99 VALUE 50.
       FD filename_var RECORD IS bytes_num BYTES.

       1  output_filename_var   PIC X(n) VALUE `c:\output.txt`.
       1  output_bytes_num      PIC 99 VALUE 50.
       FD output_filename_var RECORD IS output_bytes_num BYTES.


       1  record_variable.
        5 order_nbr     PIC 99999.
        5 data_var      PIC X(45).

       1  key_val       PIC 99999 VALUE 24331.

       1 block_variables.
         5 eof pic x value `N`.
         5 x pic 9(05).
         5 i pic 9(05).
         5 total pic 9(10).
         5 byte_size pic 9(10) value 255000.
         5 input_record occurs 5000 times.
           10 input_record_balance         pic 9(07).
           10 input_record_description     pic x(43).
           10 input_record_lf              pic x.



       1 start_time pic x(12).
       1 end_time pic x(12).

       display `Start Profiling...`.
       ACCEPT start_time FROM TIME.
       OPEN filename_var FOR READING.
       OPEN output_filename_var FOR WRITING.
       MOVE 0 TO x.
       MOVE 0 TO total.
       PERFORM UNTIL eof = `Y`
          READBLOCK byte_size BYTES FROM filename_var INTO input_record
             AT END MOVE `Y` TO eof
          ADD 1 TO x
          DISPLAY `Read Number: ` & x & `Bytes Read: ` & byte_size
          display `input_record_balance(1)-->` & input_record_balance(1)
          display `input_record_balance(5000)-->` & input_record_balance(5000)
                  & input_record_description(5000)
          IF byte_size = 255000
             display `5000 block read`
             PERFORM VARYING i FROM 1 BY 1 UNTIL i = 5000 
                COMPUTE total = total + input_record_balance(i)
             END-PERFORM
             MOVE LINEFEED TO input_record_lf(5000)
             WRITEBLOCK input_record TO output_filename_var
          END-IF
       END-PERFORM.

       display `byte_size: ` & byte_size.
       COMPUTE byte_size = byte_size / 5000.
       display `byte_size: ` & byte_size.
       IF byte_size > 0 
          PERFORM VARYING i FROM 1 BY 1 UNTIL i = byte_size
             MOVE LINEFEED TO input_record_lf(i)
             WRITEBLOCK input_record(i) TO output_filename_var
          END-PERFORM
       END-IF.



       CLOSE filename_var.
       CLOSE output_filename_var.
       DISPLAY total.

       ACCEPT end_time FROM TIME.
       display `Start time: ` & start_time.
       display `End time: ` & end_time.


       GOBACK.