fix the race condition bug

if input logs are few, sometimes it will exit before handling
any log files, just because of the WaitGroup racing