Why do you only decrease this in the error case?  Is that so you know how many files were actually processed?