added exception handling when reading file