Properly capture printing to stdout from a Scala REPL session.