* Move some block-local variable declarations to the function head.
* Split `digit_char' out as a separate function, seeing as it's used
three times.
* Rename the individual functions with a `write_...' prefix. A
corresponding (more invasive) refactoring of the input function will
have similar names, so avoid the obvious conflict.