How to get the last but not empty line in a txt file
<p>I want to get the last but not empty line in a txt file.</p>

<p>This is my code:</p>

<pre><code>string line1, line2;
ifstream myfile(argv[1]);
if(myfile.is_open())
{
    while( !myfile.eof() )
    {
        getline(myfile, line1);
        if( line1 != "" || line1 != "\t" || line1 != "\n" || !line1.empty() )
            line2 = line1;
    }
    myfile.close();
}
else
    cout &lt;&lt; "Unable to open file";
</code></pre>

<p>The problem is I cannot check the empty line.</p>

<p>Thanks in advanced</p>

<p>Zhong</p>
