Fix Issue 9599 - File.byLine doesn't function properly with take

Calling take could wrongly pop an extra line from the range.

Note: This commit just adds the unittest for the bug. The actual fix
is in the ref-counting change.
Fix unreferencing ByLine.file once empty

The file handle was not released for an empty text file.
Don't assume wrapped range has a const empty()
Make ByLine use reference-counting

Note: ByLine was documented until recently.
Don't let ByLine degenerate to a ByLineImpl