fix puts race condition

in Ruby, `puts *args` is basically calling `print *args, "\n"`, which means there is a race condition when printing output in a concurrent process.