public string Save()
{
// StringWriter.Encoding always returns UTF16. We need it to return UTF8, so the
// XmlDocument will write the UTF8 header.
Utf8Writer sw = new Utf8Writer();
sw.NewLine = newLine;
doc.Save(sw);
string txt = sw.ToString();
if (endsWithEmptyLine && !txt.EndsWith(newLine))
txt += newLine;
return txt;
}