title: Working with ifstream, data within file being called does not print
body: <p>Here is my code, the goal is open a file, read the words within that file and keep a count of how many strings are within the file. My issue is that when I run my program and call the test file, only the first string of that file is read and printed, I'm not really sure what is going wrong with it, any help would be great.</p>
  
  <p>here is what I have within my test file:</p>
  
  <p>This &amp;%file              should!!,...</p>
  
  <p>have exactly 7 words.</p>
  
  <hr>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main(){
  
      ifstream inputFile;
      string fileName, inputRead;
      string sentinel = "quit";
      int count = 0;
  
      cout&lt;&lt; "what file do you want to open?: ";
      cin&gt;&gt; fileName;
  
      inputFile.open(fileName);
  
      while(!inputFile){
          cout&lt;&lt; "\nError opening file." &lt;&lt;endl;
  
          cout&lt;&lt; "Please enter filename correctly: ";
          cin&gt;&gt; fileName;
  
          inputFile.open(fileName);
  
      }
  
      while(fileName != sentinel){
          if(inputFile){
  
              inputFile &gt;&gt; inputRead;
  
              count++;
  
              cout&lt;&lt; endl;
              cout&lt;&lt; fileName &lt;&lt; " data" &lt;&lt;endl;
              cout&lt;&lt; "*********************************\n" &lt;&lt;endl;
  
              cout&lt;&lt; inputRead &lt;&lt;endl;
  
              cout&lt;&lt; "\n*********************************" &lt;&lt;endl;
              cout&lt;&lt; fileName &lt;&lt; " has " &lt;&lt; count &lt;&lt; " words." &lt;&lt;endl;
  
              cout&lt;&lt; "\nEnter another file name or type \"quit\" to end: ";
              cin&gt;&gt; fileName;
          }
      }
  
      inputFile.close();
  
      cout&lt;&lt; endl;
  
  }
  </code></pre>