Fix I/O lag in print_posterior function

Changed calls to std:: cout to create a string then print string
at the end of the function