[Fix #1501] Make sure offenses are printed after infinite loop

Makes it easier to figure out what went wrong.

This is an improvement for #1492, which is not released yet, so no update in the change log.