Make read/write_string return undef on exception

Fixes #89978: Unreachable code in Dump()