Fixed file not being written to cache directory