Modification made to handle all the exceptions that may happen on reading files