Fix restore bug that happens when a file cannot be opened.