I wrote something similar, but in bash (and it uses the old key to rotate the new key).
I'm half-surprised no one else had written something like this before. It's a common enough problem.
[0] https://github.com/stevenkaras/bashfiles/tree/master/.ssh