title: Serializing into JSON using MemoryStream,while adding newlines C#
body: <p>I have to serialize some C# class data into JSON. For this purpose I use a MemoryStream and a DataContractJsonSerializer.</p>
  
  <pre><code>MemoryStream stream1 = new MemoryStream();
  DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Person));
  ser.WriteObject(stream1, p);
  using (FileStream file = new FileStream("Write.json", FileMode.Create, FileAccess.ReadWrite))
  {
      stream1.Position = 0;
      stream1.Read(stream1.ToArray(), 0, (int)stream1.Length);
      file.Write(stream1.ToArray(), 0, stream1.ToArray().Length);
      stream1.Close();
      file.Close();
  }
  </code></pre>
  
  <p>Running the application like this produces this output:</p>
  
  <pre><code>{"age":42,"arr":[{},{},{}],"name":"John","value":null,"w":{}}
  </code></pre>
  
  <p>However, for my task I have to produce a JSON file where each entry is entered in a new line. Example:</p>
  
  <pre><code>"SomeData":[
  {
      "SomeData" : "Value",
      "SomeData" : 0,
      "SomeData": [
          {
              "SomeData" : "Value",
              "SomeData" : 0
              ]
          }
      ]
  }, etc. etc.
  </code></pre>
  
  <p>Any ideas as to how I can do this? Thanks in advance!</p>