in reply to unreadable hash keys

vi shows even non-printable characters. I suspect it's a null byte or something along these lines. Try
hexdump -C $file
to find out what it really is.