Write file to file destination

Added code to write the html file to the right destination.
Let me know if it's ok for you.
Thanks.