WiP: actually rewrite the file in place