Just use Source.fromFile(...).getLines
as you already stated.
That returns an Iterator, which is already lazy (You’d use stream as a lazy collection where you wanted previously retrieved values to be memoized, so you can read them again)
If you’re getting memory problems, then the problem will lie in what you’re doing after getLines. Any operation like toList
, which forces a strict collection, will cause the problem.