Throw away the line
System.IO.File.Create(path);
- it's useless.
XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.Encoding = System.Text.Encoding.UTF8;
xmlSettings.Indent = true;
xmlSettings.NewLineHandling = NewLineHandling.None;
xmlSettings.NewLineOnAttributes = false;
XmlWriter writer = XmlWriter.Create(path, xmlSettings);
writer.WriteStartDocument(true);
Doc.WriteTo(writer);
writer.WriteEndDocument();
writer.Close();