Apparently the problem has to do with flushing the buffer. If I cout << "\n another sentencte\n" at the end of the program the rest of the output is also flushed. I wonder why when I tryed cout << flush; it didn't work? Well solves that problem.