For anyone having the problem of your html page being outputted in the downloaded file: call the functions ob_clean() and flush() before readfile()
For anyone having the problem of your html page being outputted in the downloaded file: call the functions ob_clean() and flush() before readfile()