Hi @Stephen Woehr ,
Adding a concrete VB example on top of what was already mentioned. File.ReadLines is the one you are looking for. It returns an IEnumerable(Of String), so lines are pulled only as you enumerate them.
Imports System.IO
' Read only the first 10 lines, nothing beyond that is read from disk
For Each line As String In File.ReadLines("C:\data\myfile.txt").Take(10)
Console.WriteLine(line)
Next
' Or stop on a condition
For Each line As String In File.ReadLines("C:\data\myfile.txt")
If line.StartsWith("END") Then Exit For
' process line
Next
If you prefer controlling each read yourself, StreamReader.ReadLine() does the same job.
Using reader As New StreamReader("C:\data\myfile.txt")
Dim line As String = reader.ReadLine()
Do While line IsNot Nothing
' process line
line = reader.ReadLine()
Loop
End Using
The key difference to watch for: File.ReadAllLines loads the entire file into memory before you can touch the first line, so that is the one to avoid for your scenario.
I hope this helps! If my answer was helpful so far, you can follow this guidance to provide some feedback. This also help others find the solution easier.