fix write file bug