Reduce eagerness of linesR

The current implementation of linesR evaluates its arguments too early, wasting system resources unnecessarily and creating a risk of user-unexpected Exceptions being thrown. This commit fixes that, to the extent possible, by delaying resource-opening and allowing resources to be re-opened when we know how.