Fix unreachable code warning

A return at the end of the function is needed for Go 1.0 not to warn,
although it's unreachable. Breaking out of the loop instead of returning
immediately to make the last return reachable.