This won't do what you expect. You do not flush here, you disable buffering of output, so if you want catch also earlier problems, so should disable buffering at top and not at bottom.