auto make directories before write file