DRY
do not use line_pos_iterator in STL algorithms directly because it causes SEGV

In incrementation of line_pos_iterator, an object which the iterator
points is accessed to check newline and it causes SEGV at the end of
input.