Handle exception during opening output file