added flush log to file

Adding Log Flush to reduce overhead at the end of long trials