Waits for stdout to flush