Add in exception handling when opening files