The buffer temporarily stores output. What this means is that it stores some output, and writes it to a file or outputs it in chunks.

This is much faster than writing in a file, so this happens to optimise resources.

In C++, we can force an output by:

outputFile.flush(); // or
outputFile << endl;