Added a WriteXml() overload that optionally leaves the stream open.