add begin/rescue block aroud file reading part