Why this matters

The bug. f.Sync() flushes buffered writes; it does *not* release the file descriptor. The handle stays open until the GC eventually reaps it (or, in long-running processes, forever). A few hundred requests per second and loadConfig starves the process of FDs.

The fix. Replace the defer f.Sync() with defer f.Close(). Close already flushes for write handles — there's no need for both. Defers fire in LIFO order at function return.

Subtle point. os.ReadFile already does the open/read/close dance. If you only need the bytes, prefer it.

Review heuristic

Read every function with an open, connect, acquire, or lock and ask: on every path out of this function — successful return, error return, exception, panic — does the matching close fire? If you can't quickly answer yes for all paths, the cleanup needs to move into a structured construct.

Classic Go review comment; CWE-772.