Updated to open log file early (as documented) and to also flush the log file after every entry