You need to pay attention to the return status from fgets(), which is NULL when there is no more data (you've reached EOF).  Even though your loop would read more lines, there aren't any to read and it should stop.

You get the same data over and over again because fgets() typically doesn't modify its string if it has got EOF on the input stream it is reading from.  You might use this for the inner loop, which has a variety of clean-ups applied (one courtesy of Serge Ballesta — removing filelength() which measures the file size in bytes instead of lines, so the values 24 and the file length are incommensurate, and anyway that function is not something you want to call on each iteration of the loop for reasons of efficiency as well).

for (i = 0; i &lt; 24; i++)
{
    if (fgets(output, sizeof(output), file) == 0)
        break;
    printf("%s", output);
}


You may need to detect EOF in the outer loop too.  Just for once, it might even be reasonable to use feof(file) there, seeing as how the outer loop is a do … while loop.

C - Print text from file, scroll with enter
I have seen this question asked in different places, but have never seen a satisfactory answer:

On different computer builds, ASUS/GIGABYTE/MSI, I constantly have outgoing connections to XXX-XXX-XXX.deploy.static.akamaitechnologies.com over HTTP Port 80, and if the connection attempts are denied, the network card (or at least internet connectivity) stops working... LAN connections still appear to work. The outgoing connections occur on every restart, and must be allowed for the network card to function properly. If the attempts are denied, the system must be restated so that the connections will be attempted again and can be allowed.

This post suggests narrowing down an offending application, but I don't see how akamai technologies can be so intertwined in so many systems, cut-off connectivity if not allowed, etc. Something about it feels like unauthorized (or at least unwanted) information transfer, at the very least a phone-home, but I have no Wirshark captures to confirm this :)

My primary guess after looking at all the symptoms: the connection attempt is trying to see if there is internet connectivity, and if the attempt fails Windows assumes there is none... But this sounds really, really dumb.
