Fix logging to use flush().