Return an iterator that read each line.

The line terminator '\n' and \r\n is removed in each line, The line are read with read_line. See this method for details.

var txt = "Hello\n\nWorld\n"
var i = new StringReader(txt)
assert i.each_line.to_a == ["Hello", "", "World"]

Unlike read_lines that read all lines at the call, each_line is lazy. Therefore, the stream should no be closed until the end of the stream.

i = new StringReader(txt)
var el = i.each_line

assert el.item == "Hello"
el.next
assert el.item == ""
el.next

i.close

assert not el.is_ok

Property definitions

core $ Reader :: each_line
	# Return an iterator that read each line.
	#
	# The line terminator '\n' and `\r\n` is removed in each line,
	# The line are read with `read_line`. See this method for details.
	#
	# ~~~
	# var txt = "Hello\n\nWorld\n"
	# var i = new StringReader(txt)
	# assert i.each_line.to_a == ["Hello", "", "World"]
	# ~~~
	#
	# Unlike `read_lines` that read all lines at the call, `each_line` is lazy.
	# Therefore, the stream should no be closed until the end of the stream.
	#
	# ~~~
	# i = new StringReader(txt)
	# var el = i.each_line
	#
	# assert el.item == "Hello"
	# el.next
	# assert el.item == ""
	# el.next
	#
	# i.close
	#
	# assert not el.is_ok
	# # closed before "world" is read
	# ~~~
	fun each_line: LineIterator do return new LineIterator(self)
lib/core/stream.nit:308,2--336,61