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.




rebol [
	Title: "Basic Input Loop"
	URL: http://rosettacode.org/wiki/Basic_input_loop
]
 
; Slurp the whole file in:
x: read %file.txt
 
; Bring the file in by lines:
x: read/lines %file.txt
 
; Read in first 10 lines:
x: read/lines/part %file.txt 10
 
; Read data a line at a time:
f: open/lines %file.txt
while [not tail? f][
	print f/1 
	f: next f ; Advance to next line.
]
close f