Functional implementation of countLines.
Added comments.