fixed write file bug