now counts lines in input properly