Count lines in input. Section 1.5.3, page 19