title: How can i loop over a text file and find for spaces between the dates and times?
body: <p>The text file is long i have many lines inside for example:</p>
  
  <pre><code>08/12/2014 00:59:41   Ok
  08/12/2014 01:05:01   Ok
  08/12/2014 01:10:01   Ok
  08/12/2014 01:15:02   Ok
  08/12/2014 01:20:01   Ok
  08/12/2014 01:25:01   Ok
  08/12/2014 01:30:01   Ok
  08/12/2014 01:35:01   Ok
  08/12/2014 01:40:01   Ok
  08/12/2014 01:45:01   Ok
  08/12/2014 01:50:01   Ok
  08/12/2014 01:55:01   Ok
  08/12/2014 02:00:01   Ok
  </code></pre>
  
  <p>The spaces except the first lines in time between each written line is about 5 minutes.
  What i need to do is loop over the text file and find the places that there is more then 5 minutes between two lines.</p>
  
  <p>For example if i find a line <code>08/12/2014 01:50:01   Ok</code> and the line right after it is <code>08/12/2014 02:55:01   Ok</code> instead <code>08/12/2014 01:55:01   Ok</code> then write in a new text file this two lines.
  So in the new text file i will see for example:</p>
  
  <pre><code>08/12/2014 01:50:01   Ok
  08/12/2014 02:55:01   Ok
  </code></pre>
  
  <p>So i know there was a problem here.</p>
  
  <p>I need somehow loop over the text file and find this places the time between each line is not like the others take this two lines and write them to a new text file.
  So if in this text file i have like 10000 lines the new text file should have 4-5 lines.</p>
  
  <p>This is how i'm creating and updating the text file now:</p>
  
  <pre><code>private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
          {
  
              if (e.Error != null)
              {
                  timer1.Stop();
                  span = new TimeSpan(0, (int)numericUpDown1.Value, 0);
                  label21.Text = span.ToString(@"mm\:ss");
                  timer3.Start();
              }
              else if (!e.Cancelled)
              {
                  label19.ForeColor = Color.Green;
                  label19.Text = "חיבור האינטרנט והאתר תקינים";
                  label19.Visible = true;
                  timer3.Stop();
                  if (timer1.Enabled != true)
                  {
                      if (BeginDownload == true)
                      {
                          timer1.Start();
                      }
                  }                
                  bool fileok = Bad_File_Testing(combinedTemp);
                  bool compared;
                  if (fileok == true)
                  {
  
                      StreamWriter w = new StreamWriter(combinedarchivefileanddir,true);
                      {
                          w.WriteLine(DateTime.Now + "   Ok");
                          w.Close();
                      }
                      File1 = new Bitmap(combinedTemp);
                      try
                      {
                          compared = ComparingImages(File1);
                      }
                      catch (WebException ex)
                      {
                          MessageBox.Show("Error: " + ex.Message + "\n\nCause: " + "Image not yet loaded.");
                          return;
                      }
                  }
                  else
                  {
                      File.Delete(combinedTemp);
                  }
                  if (File1 != null)
                  {
                      File1.Dispose();
                  }
              }
          }
  </code></pre>
  
  <p>Inside this completed event i add the part:</p>
  
  <pre><code>StreamWriter w = new StreamWriter(combinedarchivefileanddir,true);
                      {
                          w.WriteLine(DateTime.Now + "   Ok");
                          w.Close();
                      }
  </code></pre>
  
  <p>And i added just now a loop code to loop over the text file line by line:</p>
  
  <pre><code>private void ReadTextFile()
          {
              try
              {
                  int counter = 0;
                  string line;
                  StreamReader file =
                     new StreamReader(combinedarchivefileanddir);
                  while ((line = file.ReadLine()) != null)
                  {
                      //string t = line;
                      counter++;
                  }
  
                  file.Close();
              }
              catch
              {
  
              }
          }
  </code></pre>
  
  <p>How can i make now the calculation between each two lines and write the lines where the time and date spaces is not like the others to a new text file ?</p>