Improve stdout flushing.

Flushing after every line is helpful to see information quickly.

By default, Haskell application use NoBuffering when piped into
another process, which for example hides the output of cabal build
when run via a Continuous Integration server, an output-capturing
build tool, or ssh.
Merge pull request #1431 from nh2/flush-stdout

Improve stdout flushing