<pre><code>For Each line As String In System.IO.File.ReadAllLines("file.txt")
'Do Something'
Next
</code></pre>

<p>and</p>

<pre><code>Using f As System.IO.FileStream = System.IO.File.OpenRead("somefile.txt")
    Using s As System.IO.StreamReader = New System.IO.StreamReader(f)
            While Not s.EndOfStream
                    Dim line As String = s.ReadLine

                    'put you line processing code here

            End While
    End Using
End Using
</code></pre>

<p>are both showing as mostly red, I'm running a clean install of MS VS2005 and these codes were both recomended to me, am I missing something else I need to install or declare?</p>

FROM Msdn you should do the following to read all lines
```
```
Dim Lines As String()
Lines = System.IO.File.ReadAllLines("file.txt")
```
```
For the second example something like this might work
```
```
Dim sr as New StreamReader("somefile.txt")
Dim line as String = sr.ReadLine()
Do While Not line is Nothing
    line = sr.ReadLine()
    'do something else
Loop
```
```
I just created the following VB.Net Console app and it works fine:
```
```
Imports System.IO

Module Module1

Sub Main()
    Dim sr As New StreamReader("somefile.txt")
    Dim line As String = sr.ReadLine()
    Do While Not line Is Nothing
        line = sr.ReadLine()
        'do something else
    Loop

End Sub

End Module
```
```