It is related to the output stream being buffered...fully buffered if writing to a file and line buffered if writing to a terminal. As printf() writes to a terminal the stdout stream is line buffered so all that is needed is adding a newline character to the end of the output strings.