fix file->write(), failed on checking if folder existed