refactoring sample4 stringiterator reading of line