Encoding whitespace in ssid using '+'
Flush just after writing a log into output stream.

This fixes a problem that it takes a few minutes to write logs into a
file actually.