Output key into temporary file

We put up a valiant effort, trying to force bash to make the
temporary file with herestrings, but ultimately we fell to the
treachery of `/dev/stdin: Stale file handle`. Remember us.