title: Only printing in console lines containing 'the' in text file: Visual Basic
body: <p>Help!!
  I have been set this task but i'm really unsure how to do this:</p>
  
  <pre><code>    Sub Main()
  
      Dim filePath As String = "C:\...\Projects\testing.txt"
      Dim fileHolder As System.IO.StreamReader
      Dim line As String
  
      fileHolder = My.Computer.FileSystem.OpenTextFileReader(filePath)
      line = fileHolder.ReadLine()
  
      While line &lt;&gt; Nothing
          Console.WriteLine(line)
          Console.WriteLine("*****")
          line = fileHolder.ReadLine()
      End While
      Console.ReadKey()
  
      End Sub
  </code></pre>
  
  <p>"Edit the above program so that it only writes lines beginning with “The” to the console. You may find it helpful to revisit the lesson on String Handling to complete this task."</p>
  
  <p>I have tried using if statements inside the while loop or a Do Until loop inside the While one, however this meant it would print the first line that contained "the" and not the third line that also contained "the", as the second line didn't.
  Here is the (really bad code) that has failed me so far:</p>
  
  <pre><code>    Dim filePath As String = "C:\...\Projects\testing.txt"
      Dim fileHolder As System.IO.StreamReader
      Dim line As String
  
      fileHolder = My.Computer.FileSystem.OpenTextFileReader(filePath)
      line = fileHolder.ReadLine()
      Dim the As String = "the"
  
      While line &lt;&gt; Nothing
          If line.ToUpper.Contains(the.ToUpper) Then
              Console.WriteLine(line)
              Console.WriteLine("*****")
              line = fileHolder.ReadLine()
          End If
      End While
      Console.ReadKey()
  </code></pre>
  
  <p>Thank you for any help!! </p>