started working improvements to the write file