title: Text file split in blocks vb.net
body: <p>I am trying to go through my text file and create a new file that will contain only the text I require. My current line looks like:</p>
  <pre><code>Car-1I
  Colour-39
  Cost-328
  Dealer-28
   
  Car-2
  Colour-30
  Cost-234
  </code></pre>
  <p>For each block of text I would like to read the first line, if the first line ends with an I, then read the next line, if that line contains a colour 39, then I would like to save the whole block of text to another file. If these two conditions aren't met, I dont want to save my values to the new text file.</p>
  <p>Before anything about saving my values in classes are mentioned, these blocks of text can vary in size and values, so I dont always have a set range of values which is why i need to skip to the blank line</p>
  <pre><code>IO.File.WriteAllText(&quot;C:\Users\test2.txt&quot;, &quot;&quot;) 'write to new file
      Dim sKey As String
      Dim sValue As Integer
    
      For Each filterLine As String In File.ReadLines(&quot;C:\Users\test.txt&quot;)
          sKey = Split(filterLine, &quot;:&quot;)(0)
          sValue = Split(filterLine, &quot;:&quot;)(1)
          If Not sValue.EndsWith(&quot;I&quot;) Then
  
  
          ElseIf sValue.EndsWith(&quot;I&quot;) Then
  
          
          End If
  
      Next
  </code></pre>