A somewhat better approach.
Remove duplication of error-checking before writing phonebook.