File Stream C#

using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
internal class Utility
{
    public static void SerializeXml(Stream output, object data)
    {
        XmlSerializer xs = new XmlSerializer(data.GetType());
        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Encoding = Encoding.UTF8;
        XmlWriter writer = XmlTextWriter.Create(output, settings);
        xs.Serialize(writer, data);
        writer.Flush();
        writer.Close();
    }
}