Can we put the flush inside the foreach loop?