Correct misplaced loop close

checkCount conditional should run after matching engine loop has
completed.