Make count command work better when output is piped to another command

* Flush stdout after printing each line
* Catch Ctrl-C
Allow folder names to be specified when using "count" command