handle errors in reading file