``EINTR == 4`` on Linux, which is a valid stream value, so it's not safe to assume that ``EINTR`` means we should quit. According to the standard ``fgetc`` is only ever supposed to return a character from the stream, or ``EOF``. I find it a bit surprising that this can happen at all. Have you verified that ``EINTR`` is returned every time?

If it's a problem that an empty file stays in the loop, you can try using ``feof()`` instead. It's supposed to tell you when you are at the end of a file.