The grammar for an endif-line defines it as #endif followed by a new-line ($6.10.1 of the C++23 standard). If the new-line is missing at the end of the file, #endif will not be correctly recognized.
Most IDEs will automatically add a new-line at the end of the file if it is missing when saving.