added check if cache file can be written