Handle error when opening files