why such a difference in file contents C# <p>My intention is to write a <code>byte[]</code> to a file. Code snippet is below:</p> <pre><code>byte[] stream = { 10, 20, 30, 40, 60 }; for (int i = 0; i &lt; 2; i++) { FileStream aCmdFileStream = new FileStream(@"c:\binarydata.txt", FileMode.Append, FileAccess.Write, FileShare.None); StreamWriter aStreamWriter = new StreamWriter(aCmdFileStream); for (int ii = 0; ii &lt; stream.Length; ii++) { aStreamWriter.Write(stream[ii]); aStreamWriter.WriteLine(); aStreamWriter.BaseStream.Write(stream,0,stream.Length); } aStreamWriter.Close(); } </code></pre> <p>Output of this code snippet</p> <pre><code>(&lt; (&lt; (&lt; (&lt; (&lt;10 20 30 40 60 (&lt; (&lt; (&lt; (&lt; (&lt;10 20 30 40 60 </code></pre> <p>When <code>StreamWriter.Write()</code> is used it dumps the values which are stored in array. But <code>StreamWriter.BaseStream.Write(byte[],int offset, int length)</code>, the values are totally different. What is the reason for this?</p>