This PR aims to reduce build time by replacing multiple file(WRITE|APPEND ...)
commands with a single file(WRITE ...)
command.
Due to differences in implementation (e.g., filesystem design, system calls, caching), a noticeable improvement in build time is observed only on Windows.
Additionally, the code has been refactored to remove the remainder
local variables.