OK. thanks for the reply.
The problem is its just not writing the HTML file.. the code is obviously bombing out around where i introduce this code. I cant troubleshoot properly because i am adding the extra lines of code into something that is already live, It only runs once a day at 5pm.
Its on a scheduled task and i cant read any errors msgs off the console. I guess i should try and create some kind of logfile.