Check exit condition after the cat instead of inline.