title: Writing 2 rows to TXT in 1 loop
body: <p>I have a DataTable like this:</p>
  <pre><code>TerminalNo      Payment      ORNO    Time
  PHW0501         1,000.00     1       1:05pm
  PHW0502         2,000.00     2       1:05pm
  PHW0501         3,000.00     3       1:10pm
  PHW0502         4,000.00     4       1:10pm
  PHW0501         5,000.00     5       1:15pm
  PHW0502         6,000.00     6       1:15pm
  PHW0501         7,000.00     7       1:20pm
  PHW0502         8,000.00     8       1:20pm
  </code></pre>
  <blockquote>
  <p>Everytime that payment has been made on both Terminal(at the same time
  or not), I want to get the <strong>Payment</strong> for both <strong>TerminalNo</strong> and
  write it on a different <strong>TXT file</strong> with different folder path.</p>
  </blockquote>
  <p>Like this:</p>
  <pre><code>    FolderPath1/Txt1 
   PHW0501, 1,000.00, 1:05pm, 1
  
      FolderPath2/Txt2
  PHW0502, 2,000.00, 1:05pm, 2
  </code></pre>
  <p>I only get this:</p>
  <pre><code>Folder1/Txt1 = PHW0501, 1,000.00, 1:05pm, 1
  </code></pre>
  <p>This is my code:</p>
  <pre><code>DataRow rw = dtTransaction.AsEnumerable().FirstOrDefault(tt =&gt; tt.Field&lt;string&gt;(&quot;TerminalNo&quot;) == &quot;PHW0501&quot;);
  DataRow rw2 = dtTransaction.AsEnumerable().FirstOrDefault(tt =&gt; tt.Field&lt;string&gt;(&quot;TerminalNo&quot;) == &quot;PHW0502&quot;);
  string fileName1 = GeneratedPath1 + DateTime.Now.ToString(&quot;MMddyyyy&quot;) + &quot;.txt&quot;;
  string fileName2 = GeneratedPath2 + DateTime.Now.ToString(&quot;MMddyyyy&quot;) + &quot;.txt&quot;;
  for (int i = 0; i &lt; dtTransaction.Rows.Count; i++)
  {
      if (rw.ItemArray[4].ToString().Equals(&quot;PHW0501&quot;))
      {
          if (dtTransaction.Rows[i][&quot;TerminalNo&quot;].ToString().Equals(&quot;PHW0501&quot;) &amp;&amp; !dtTransaction.Rows[i][&quot;ORNo&quot;].ToString().Equals(&quot;&quot;))
          {
              string Time = dtTransaction.Rows[i][&quot;Time&quot;];
              double Payment = -double.Parse(dtTransaction.Rows[i][&quot;Payment&quot;].ToString());
              int ORNo = dtTransaction.Rows[i][&quot;ORNo&quot;].ToString();
  
              using (StreamWriter sw = File.AppendText(fileName1))
              {
                  sw.Write(&quot;PHW0501&quot; + &quot;,&quot;);
                  sw.Write(Payment + &quot;,&quot;);
                  sw.Write(Time + &quot;,&quot;);
                  sw.Write(ORNo);
              }   
          }
      }
      if (rw2.ItemArray[4].ToString().Equals(&quot;PHW0502&quot;))
      {
          if (dtTransaction.Rows[i][&quot;TerminalNo&quot;].ToString().Equals(&quot;PHW0502&quot;) &amp;&amp; !dtTransaction.Rows[i][&quot;ORNo&quot;].ToString().Equals(&quot;&quot;))
          {
              string Time = dtTransaction.Rows[i][&quot;Time&quot;];
              double Payment = double.Parse(dtTransaction.Rows[i][&quot;Payment&quot;].ToString());
              int ORNo = dtTransaction.Rows[i][&quot;ORNo&quot;].ToString();
  
              using (StreamWriter sw = File.AppendText(fileName2))
              {
                  sw.Write(&quot;PHW0502&quot; + &quot;,&quot;);
                  sw.Write(Payment + &quot;,&quot;);
                  sw.Write(Time + &quot;,&quot;);
                  sw.Write(ORNo);
              }
          }
      }
  }
  </code></pre>