Write build.ninja in temporary file, then move.

This guards against failures during the write process.

This has no user-visible impact unless reinit fails.