LINE INPUT [ # Stream , ] Variable

Reads an entire line of text from the text stream Stream into a String Variable.

If the stream Stream is not specified, then the standard input is used.

The entire line is read, except the end-of-line delimiter.

The end-of-line delimiter can be defined with the Stream.EndOfLine property. It is gb.Unix by default, which selects a single Chr$(10) character.

Do not use this instruction to read from binary files, because you will lose the linefeed characters. Use READ instead.

Do not use this instruction inside the Read event of a process that does not necessarily send a newline (because it is printing a prompt for example). It will block forever waiting for the newline character.


DIM hFile AS Stream
DIM sOneLine AS String

' Print a file to standard output
hFile = OPEN "/etc/hosts" FOR INPUT

WHILE NOT Eof(hFile)
  LINE INPUT #hFile, sOneLine
  PRINT sOneLine

CLOSE #hFile

See also