chore(release): fix duplicate argument in NamedTemporaryFile (#4014)

In GitHub.update_issue_body, tempfile.NamedTemporaryFile was called
with both a positional argument and a keyword argument for the mode,
raising a TypeError for multiple values of 'mode'. Additionally,
standard output was not flushed before writing fatal error messages
to standard error upon release tool failures.

Pass mode only as a keyword argument with UTF-8 encoding when writing
temporary files for issue body updates, flush stdout prior to logging
fatal exceptions, and add unit test coverage for update_issue_body.
diff --git a/tests/tools/private/release/gh_test.py b/tests/tools/private/release/gh_test.py
index b8c3460..7e19b22 100644
--- a/tests/tools/private/release/gh_test.py
+++ b/tests/tools/private/release/gh_test.py
@@ -77,3 +77,20 @@
     gh_obj = GitHub("foo/bar")
     gh_obj._run_gh("issue", "list")
     auto_patch_cmd_helpers.run_gh.assert_called_with("issue", "list")
+
+
+def test_update_issue_body(gh, auto_patch_cmd_helpers):
+    captured_body = {}
+
+    def mock_run(*args, **kwargs):
+        for arg in args:
+            if isinstance(arg, str) and arg.startswith("--body-file="):
+                path = arg.split("=", 1)[1]
+                with open(path, encoding="utf-8") as f:
+                    captured_body["content"] = f.read()
+        return None
+
+    auto_patch_cmd_helpers.run_gh.side_effect = mock_run
+    gh.update_issue_body(123, "new body content")
+    auto_patch_cmd_helpers.run_gh.assert_called_once()
+    assert captured_body["content"] == "new body content"
diff --git a/tools/private/release/gh.py b/tools/private/release/gh.py
index 9d157f3..17fcd59 100644
--- a/tools/private/release/gh.py
+++ b/tools/private/release/gh.py
@@ -307,7 +307,7 @@
             issue_num: The issue number.
             body: The new body content.
         """
-        with tempfile.NamedTemporaryFile("w", delete=False, mode="w") as f:
+        with tempfile.NamedTemporaryFile(mode="w", delete=False, encoding="utf-8") as f:
             f.write(body)
             f.flush()
             temp_path = f.name
diff --git a/tools/private/release/release.py b/tools/private/release/release.py
index 72c427a..7f1896e 100644
--- a/tools/private/release/release.py
+++ b/tools/private/release/release.py
@@ -64,6 +64,7 @@
         # args.command is the run_from_args classmethod of the selected command
         exit_code = args.command(args)
     except Exception as e:
+        sys.stdout.flush()
         print(f"Fatal error: {e}", file=sys.stderr)
         if hasattr(e, "__notes__"):
             for note in e.__notes__: