This patch fixes the REPL's output from interleaving with the status line by locking the stream before printing.