When `break`ing out of loops, the last newline isn't written. See if there's a way to fix this smoothly, or if not, consider a custom `break` mechanism.