C# close StreamWriter
<p>Im trying to close a text file that I have created and then read this back into a HTMLDocumentClass.</p>

<p>This is the code</p>

<pre><code>StreamWriter outfile = 
    new StreamWriter(StripHTMLComps.Properties.Settings.Default.TempFileName);
outfile.Write(HTML);
outfile.Close();

HTMLDocumentClass doc = null;
doc = new HTMLDocumentClass();
IPersistFile persistFile = (IPersistFile)doc;
persistFile.Load(StripHTMLComps.Properties.Settings.Default.TempFileName, 0);
GC.SuppressFinalize(persistFile);
int start = Environment.TickCount;
while (doc.readyState != "complete")
{
    if (Environment.TickCount - start &gt; 10000)
    {
    }
}
</code></pre>

<p>The document says loading but never completes, I believe that it believes the document is still in being used by another process.</p>

<p>Any ideas?</p>
