Refactor into replaceExtension().
Save states are written to proper files, not /tmp/foo