Delay the log-file writing till the end of the execution