fix on write file if directory doesn't exist