Fix race condition.
Fix typo.
Fix the order of candidates.
Enable case-insensitive flag.
Remove debug code.
Enable input from file.
Add isatty() for each platform.
Separate the file.