Free memory on file I/O error