Improved xml writing files