This occurs with large files. The end of a conditional block IF ... ELSE ... END IF can be soiled with hundreds of unprintable characters. Then ascii 0 disables the file rest. The first indication of the injured file is, in my case, a falling compilation.
On UNIX, the file can be saved. The rescue consists in replacing ASCII 0 with an unused printable character, e.g. '`'. E.g. file.c rescue: tr '