Stream a text file line by line with StreamReader
C#
using System.Collections.Generic;
using System.IO;
static IEnumerable<string> ReadLines(string path)
{
using var reader = new StreamReader(path);
while (reader.ReadLine() is { } line)
{
if (line.Length == 0)
continue;
yield return line.TrimEnd();
}
}