fix race condition on log file