Writing rows from a DataTable is creating a run-on write: how do I preserve each line as it is written?
<p>Given this code:</p>

<pre><code>using (StreamWriter sw = File.CreateText(file))
{
    for (int r = 0; r &lt; originalDataTable.Rows.Count; r++)
    {
        for (int c = 0; c &lt; originalDataTable.Columns.Count; c++)
        {
            var rowValueAtColumn = originalDataTable.Rows[r][c].ToString();

            var valueToWrite = string.Format(@"{0}{1}", rowValueAtColumn, "\t");

            if (c != originalDataTable.Columns.Count)
                sw.Write(valueToWrite);
            else 
                sw.Write(valueToWrite + @"\n");
        }
    }
}
</code></pre>

<p>I am trying to write a DataRow back to a file one row at a time; however, the file it is creating is creating a run-on sentence where all the data being written to the file is just in one line. There should be 590 individual lines not just one. </p>

<p>What do I need to add to the code above so that my lines are broken out as they are in the data table? My code just doesn't seem to be working.</p>
