HtmlAgilityPack (HAP) will not necessarily write out the same HTML it reads. If you check the source, you'll see that the writing (WriteTo
method) pushes out parsed nodes. If the original server sends invalid HTML, HAP will clean it up as part of its parsing.
If you need to save the original, use WebClient.DownloadString, and load that saved file with HAP.