That is likely because the fclose causes the data to be ACTUALLY written to disk - up until the fclose, the OS just keeps it all in RAM, but once you close the file, it says "Ok, that's it, lets...