Added 5 seconds timeout to force output buffer flush