EachLine: close stream only if automatically opened. fixes #3228