<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_by_hash(hashval: str):
 """ Remove the key whose md5 sum matches hashval. :raises: KeyError if the hashval wasn't found """

    key_details = get_keys()
    with authorized_keys('w') as ak:
        for keyhash, key in key_details:
            if keyhash != hashval:
                ak.write(f'{key}\n')
                break
        else:
            raise KeyError(hashval)