Fix logging in run.sh to avoid concurrency problems.