only open log.txt on processor 0

Only processor 0 will be writing into the file output/log.txt anyway, so
we only need to open it there. This might also fix some filesystem race
conditions.