ANS X3.23-1968

JDoodle - Online COBOL Compiler IDE ...
(Ctrl+C, open link in new panel, Ctrl+V, Submit)

identification division.
program-id. TYPEWRITER.   *> keyboard - memory - screen
    *> structured code without scope-delimiters
    *> *** execute in Interactive mode ***
    
data division.
working-storage section.
1   TW-MEMORY.
 2   INP-LINE pic x(80) occurs 5.
77  I pic 9.

procedure division.
    move space to TW-MEMORY
    display "write text max 5 times, at end write e:"  display " " 

    perform INP-PROC varying I from 1 by 1 until I > 5
    display "   entry is complete"  display " "

    perform OUT-PROC varying I from 1 by 1 until INP-LINE(I) = "e" or I > 5
    display "   the work is finished ***"
    stop run.
    
INP-PROC.
    accept INP-LINE(I)
    if INP-LINE(I) = "e" 
        move 6 to I.
OUT-PROC.
    display I ". " INP-LINE(I).

I = keyboard, W = memory, O = screen:

write text max 5 times, at end write e:
 
aaaaaaa
bbbbbbb
ccccccc
e
   entry is complete
 
1. aaaaaaa                                                                         
2. bbbbbbb                                                                         
3. ccccccc                                                                         
   the work is finished ***