title: Adding newline to byte sequence when writing to filestream
body: <p>I am trying to add <code>Newline</code> when writing to a <code>FileStream</code> and it seems that even if i try :<br>
  <code>\r\n</code> or<Br>
  <code>\\r\\n</code> or<br>
  <code>System.Environment.Newline</code> <br>
  the result file will not add the newlines.It will just add the characters as they are:</p>
  
  <p><code>public static NewLine=&gt;System.Environment.Newline;</code></p>
  
  <pre><code> string header = $"Client:{index}{Newline}Date:{DateTime.Now.ToString()}{Newline}\r\nData:{Newline}";
   using (FileStream stream = new FileStream(filePath, FileMode.OpenOrCreate,FileAccess.ReadWrite, FileShare.ReadWrite))   
   {
      await stream.WriteAsync(header.ToMemory());
  
      ReadOnlyMemory&lt;byte&gt; memory = Enumerable.Aggregate(
                                      responses,
                                      string.Empty,
                                      (acc, src) =&gt; acc + Newline + src.ToString()).ToMemory();
      await stream.WriteAsync(memory);
   }
  </code></pre>
  
  <p>In our case <code>NewLine</code> is <code>System.Environment.Newline</code>, but i have tried all of the above combinations and the output of the file is:</p>
  
  <pre><code>"Client:0\r\nDate:23.08.2018 21:56:04\r\n\r\nData:\r\n""\r\n00:00:00.3222976"510"
  </code></pre>
  
  <p>And i wanted </p>
  
  <pre><code> Client:0
   Date:23.08.2018 
   Data:  --data should start from below
   00:00:00.3222976 510
   .........
  </code></pre>
  
  <p><strong>ToMemory</strong></p>
  
  <pre><code> public static ReadOnlyMemory&lt;byte&gt; ToMemory(this object obj)
          {
              string dataString = JsonConvert.SerializeObject(obj);
              ReadOnlyMemory&lt;byte&gt; dataBytes = Encoding.UTF8.GetBytes(dataString);
              return dataBytes;
          }
  </code></pre>