Added try catch statement for opening files