title: comparing two text files
body: <p>I have two text files <code>bala.txt</code> and <code>bala1.txt</code></p>
  
  <p>bala.txt contains text line by line as</p>
  
  <pre><code>balamurugan,rajendran,chendurpandian
  christopher
  updateba
  </code></pre>
  
  <p>bala1.txt contains text line by line as</p>
  
  <pre><code>ba
  </code></pre>
  
  <p>Here i need to check bala1.txt with bala.txt and write into a log file as</p>
  
  <pre><code>LineNo : 0 : balamurugan,rajendran,chendurpandian
  LineNo : 2 : updateba
  </code></pre>
  
  <p>now its writing only one line as</p>
  
  <pre><code>LineNo : 0 : balamurugan,rajendran,chendurpandian
  </code></pre>
  
  <p>after that while loop is getting out</p>
  
  <p>Here is my code</p>
  
  <pre><code>while (((line = file.ReadLine()) != null &amp; (line2 = file2.ReadLine()) != null))
                          {
                              if (line.Contains(line2))
                              {
                                  dest.WriteLine("LineNo : " + counter.ToString() + " : " + line + "&lt;br /&gt;");
                              }
                              counter++;
                          }
  </code></pre>
  
  <p>any suggestion??</p>
  
  <p>EDIT:</p>
  
  <pre><code>string FilePath = txtBoxInput.Text;
      string Filepath2 = TextBox1.Text;
      int counter = 0;
      string line;
      string line2;
  
  
          DirectoryInfo Folder = new DirectoryInfo(textboxPath.Text);
          var dir = @"D:\New folder\log";
  
          if (Folder.Exists)
          {
              if (!Directory.Exists(dir))
                  Directory.CreateDirectory(dir);
          }
          if (File.Exists(FilePath) &amp; File.Exists(Filepath2))
          {
              // Read the file and display it line by line.
              using (var file = File.OpenText(FilePath))
              using (var file2 = File.OpenText(Filepath2))
              using (var dest = File.AppendText(Path.Combine(dir, "log.txt")))
              {
                  while (((line = file.ReadLine()) != null &amp; (line2 = file2.ReadLine()) != null))
                  {
                      if (line.Contains(line2))
                      {
                          dest.WriteLine("LineNo : " + counter.ToString() + " : " + line + "&lt;br /&gt;");
                      }
  
                      counter++;
                  }
  
              }
  </code></pre>
  
  <p>}</p>
  
  <p>EDIT(2):
    I need to create two text files into the folder log and write into that text files as <code>ba.txt</code> with contents as</p>
  
  <pre><code>LineNo : 0 : balamurugan,rajendran,chendurpandian
  LineNo : 2 : updateba
  </code></pre>
  
  <p>and <code>ra.txt</code> with contents as </p>
  
  <pre><code>LineNo : 0 : balamurugan,rajendran,chendurpandian
  </code></pre>
  
  <p>Any Suggestion??</p>
  
  <p>EDIT(3):
   I need to create a folder named <code>Log</code> through code and in that log folder <code>ba.txt</code> and <code>ra.txt</code> have to be created.</p>