Rewrote with-cache-file to leave the old file intact in case an error occurs during cache generation.