using fstream to write XML files