* corpus charka — nivel 7: E/S de ficheros (escribir y releer)
IDENTIFICATION DIVISION.
PROGRAM-ID. FICHERO.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT DATOS ASSIGN TO '/tmp/charka-corpus-18.dat'
        ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD DATOS.
01 REGISTRO PIC X(20).
WORKING-STORAGE SECTION.
01 WS-FIN  PIC X VALUE 'N'.
   88 FIN-DATOS VALUE 'S'.
01 WS-CONT PIC 9(3) VALUE 0.
PROCEDURE DIVISION.
MAIN.
    OPEN OUTPUT DATOS.
    WRITE REGISTRO FROM 'PRIMERA LINEA'.
    WRITE REGISTRO FROM 'SEGUNDA LINEA'.
    WRITE REGISTRO FROM 'TERCERA LINEA'.
    CLOSE DATOS.
    OPEN INPUT DATOS.
    PERFORM UNTIL FIN-DATOS
        READ DATOS
            AT END SET FIN-DATOS TO TRUE
            NOT AT END
                ADD 1 TO WS-CONT
                DISPLAY REGISTRO
        END-READ
    END-PERFORM.
    CLOSE DATOS.
    DISPLAY 'LINEAS LEIDAS = ' WS-CONT.
    STOP RUN.
