Make sure old file exists before doing things to it.

From #6507.