Input loop is part of Short Circuit's Console Program Basics selection.
Task

Read from a text stream either word-by-word or line-by-line until the stream runs out of data.

The stream will have an unknown amount of data on it.




( put$("This is
a three line
text","test.txt",NEW)
& fil$("test.txt",r)
& fil$(,STR," \t\r\n")
& 0:?linenr
&   whl
  ' ( fil$:(?line.?breakchar)
    &   put
      $ ( str
        $ ( "breakchar:"
            ( !breakchar:" "&SP
            | !breakchar:\t&"\\t"
            | !breakchar:\r&"\\r"
            | !breakchar:\n&"\\n"
            | !breakchar:&EOF
            )
            ", word "
            (1+!linenr:?linenr)
            ":"
            !line
            \n
          )
        )
    )
& (fil$(,SET,-1)|out$"file closed")
);