title: ifstream usage and user input not outputting content to read
body: <p>I'm practicing <code>ifstream</code> usage. I want the user to enter the file they want to read, in this example <strong>num1.txt</strong> specifically. I want the console to read one letter from <code>num1.txt</code> and output it on its own line.</p>
  <p>I've ran the code below, and after entering <code>&quot;num1.txt&quot;</code> into the console, I get nothing back. I've tried moving around <code>cout &lt;&lt; num &lt;&lt; endl;</code> to the inner <code>do</code> statement, but it ends up repeating the number <code>10</code> an infinite amount.</p>
  <p>What am I doing wrong here?</p>
  <p>Contents in <code>num1.txt</code>:</p>
  <pre class="lang-none prettyprint-override"><code>2 4 6 8 10
  </code></pre>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main() {
      string fileName, cont;
      ifstream inputFile;
  
      do {
          int num = 0;
          int total = 0;
          cout &lt;&lt; &quot;Please enter the file name: &quot;;
          cin &gt;&gt; fileName;
          inputFile.open(fileName);
  
          if (inputFile.is_open()) {
              do {
                  inputFile &gt;&gt; num;
                  total += num; 
              }
              while(num &gt; 0);
  
              if (total != 0) {
                  cout &lt;&lt; num &lt;&lt; endl;
                  cout &lt;&lt; &quot;Total is: &quot; &lt;&lt; total &lt;&lt; endl;
              }
          }
          else {
              cout &lt;&lt; &quot;Failed to open file.&quot; &lt;&lt; endl;
          }
  
          inputFile.close();
          cout &lt;&lt; &quot;Do you want to continue processing files? (yes or no): &quot; &lt;&lt; endl;
          cin &gt;&gt; cont;
      }
      while (cont == &quot;yes&quot;);
  }
  </code></pre>