catching errors for file accessing