The name does not exist in the current context. Why? : <p>My code is:</p>

<pre><code>        if (textBox1.Text != "")
        {
            StreamReader tx = new StreamReader(textBox1.Text);
        }
        else
        {
            StreamReader tx = new StreamReader("new.txt");
        }

        string line;

        while ((line = tx.ReadLine()) != null)
        {
</code></pre>

<p>If i delete "if" and leave it as:</p>

<pre><code>        StreamReader tx = new StreamReader("new.txt");


        string line;

        while ((line = tx.ReadLine()) != null)
        {
</code></pre>

<p>Everything works. Why does if mess up my code?</p>
