Make error log helper more robust against races

Due to the asynchronous nature of the logger, the line in the log file
may not immediately be written.  This changes the helper to poll the
logfile until a line is written.