title: Save YamlStream from YamlDotNet Plugin to text file
body: <p>I need to construct a YAML configuration file for a ROS node, inside a C# application. Basically, users specifies parameters values, and I fetch those values to write the YAML file. </p>
  
  <p>I'm developing on MonoDevelop with help of the great YamlDotNet plugin by @Antoine Aubry. However, starting from this question : <a href="https://stackoverflow.com/questions/37116684/build-a-yaml-document-dynamically-from-c-sharp">Build a Yaml document dynamically from c#</a>, I cannot find a way to save the YAML document to a simple text file, instead of outputting it in the console.</p>
  
  <p>I've been looking into StreamWriter, TextWriter, Byte Converter and so many things that I'm a little lost here. 
  I'm using this example code, in this fiddle <a href="https://dotnetfiddle.net/0raqgN" rel="nofollow noreferrer">https://dotnetfiddle.net/0raqgN</a></p>
  
  <pre><code>  var address = new YamlMappingNode(
          new YamlScalarNode("street"), new YamlScalarNode("123 Tornado Alley\nSuite 16") { Style = YamlDotNet.Core.ScalarStyle.Literal },
          new YamlScalarNode("city"), new YamlScalarNode("East Westville"),
          new YamlScalarNode("state"), new YamlScalarNode("KS")
      ) { Anchor = "main-address" };
  
    var stream = new YamlStream(
          new YamlDocument(
              new YamlMappingNode(
                  new YamlScalarNode("repeipt"), new YamlScalarNode("Oz-Ware Purchase Invoice"),
                  new YamlScalarNode("date"), new YamlScalarNode("2007-08-06"),
                  new YamlScalarNode("customer"), new YamlMappingNode(
                      new YamlScalarNode("given"), new YamlScalarNode("Dorothy"),
                      new YamlScalarNode("family"), new YamlScalarNode("Gale")
                  ),
                  new YamlScalarNode("items"), new YamlSequenceNode(
                      new YamlMappingNode(
                          new YamlScalarNode("part_no"), new YamlScalarNode("A4786"),
                          new YamlScalarNode("descrip"), new YamlScalarNode("Water Bucket (Filled)"),
                          new YamlScalarNode("price"), new YamlScalarNode("1.47"),
                          new YamlScalarNode("quantity"), new YamlScalarNode("4")
                      ),
                      new YamlMappingNode(
                          new YamlScalarNode("part_no"), new YamlScalarNode("E1628"),
                          new YamlScalarNode("descrip"), new YamlScalarNode("High Heeled \"Ruby\" Slippers"),
                          new YamlScalarNode("price"), new YamlScalarNode("100.27"),
                          new YamlScalarNode("quantity"), new YamlScalarNode("1")
                      )
                  ),
                  new YamlScalarNode("bill-to"), address,
                  new YamlScalarNode("ship-to"), address,
                  new YamlScalarNode("specialDelivery"), new YamlScalarNode("Follow the Yellow Brick\nRoad to the Emerald City.\nPay no attention to the\nman behind the curtain.") { Style = YamlDotNet.Core.ScalarStyle.Literal }
              )
          )
      );
  </code></pre>
  
  <p>The last thing I tried was this :</p>
  
  <pre><code>StreamWriter sw = new StreamWriter (@"/home/guillaume/test_yaml.yaml");
  stream.Save (sw);
  </code></pre>
  
  <p>But the file test_yaml.yaml remains empty (0 octets) every damn time, whereas I want it to look like this : </p>
  
  <pre><code>  repeipt: Oz-Ware Purchase Invoice
    date: 2007-08-06
    customer:
      given: Dorothy
      family: Gale
    items:
    - part_no: A4786
      descrip: Water Bucket (Filled)
      price: 1.47
      quantity: 4
    - part_no: E1628
      descrip: High Heeled "Ruby" Slippers
      price: 100.27
      quantity: 1
    bill-to: &amp;main-address
      street: |-
        123 Tornado Alley
        Suite 16
      city: East Westville
      state: KS
    ship-to: *main-address
    specialDelivery: |-
      Follow the Yellow Brick
      Road to the Emerald City.
      Pay no attention to the
      man behind the curtain.
    ...
  </code></pre>
  
  <p>Sorry if this looks like a noob question! </p>