Detect lines that should never be toggled: shebang and encoding pragma.
Only checks the first two non-blank lines (shebangs are only valid on line 1,
PEP 263 encoding pragmas on lines 1-2).
Returns 0-based line indices of protected lines.
Read file content with a specified encoding.
Supports any encoding label recognized by the Encoding Standard
(e.g., “utf-8”, “latin-1”, “iso-8859-1”, “windows-1252”, “ascii”).
Write file content atomically using a temp file + rename.
If temp_suffix is provided, uses path.<suffix> as the temp file name.
Otherwise uses a NamedTempFile in the same directory.
If no_dereference is true and path is a symlink, writes to the symlink’s
target instead of replacing the symlink.