fixed write file exception