fix bug about write file