only flush output when also sending headers