Oh wait, I missed "run on linux" with "Mac file with CR".
OK, answer: The documentation fgets()explicitly refers to the "new line" as the line terminator. Especially you should not expect that Unix / Linux implementations have heard of the old Mac concept of CR as a line terminator; therefore it is not surprising that they fgetsdo not see these CRs as the end of a line.
Update:
My strong recommendation to avoid most of the problem is to use a command-line utility such as trto simply translate the file before throwing your program into it.