title: Why is reading a file using `array` successfully reads the file and terminates with an unknown error?
body: <p>I am trying to read from a specific line/block using <code>array</code> manipulation of index, but the program is terminating with an unknown error after reading from the third line to end, and returning <code>255</code> , How to achieve it using the same method I implemented in the code if this is possible?</p>
  <blockquote>
  <p>Create a file with 10 blocks and name it <code>datafile.txt</code> then try to
  read the file starting from the third block using <code>index = 3</code> it will
  read from the the whole file starting from the 3rd line and then terminates with 255 telling file not accessible.</p>
  <p>The expected output is it should start reading from the third block to
  the end of the file <code>eof</code> and prints the output without any error.</p>
  </blockquote>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  int main()
  {
      ifstream datafile(&quot;datafile.txt&quot;);
      if(datafile)
      {
          cout &lt;&lt; &quot;The file is accessible to read&quot; &lt;&lt; '\n';
          const int DataCounterArray = 9;
          string nameList[DataCounterArray] = {&quot;&quot;};
          string getDataTemporary = {&quot;&quot;};
          int index = 3;
       while (!datafile.eof())
          {
              nameList[index] = getDataTemporary;
              index++;
              datafile &gt;&gt; getDataTemporary;
              cout &lt;&lt; getDataTemporary &lt;&lt; '\n';
          }
          for (int i=0; i &lt; DataCounterArray; i++)
          {
              cout &lt;&lt; nameList[i] &lt;&lt; '\n';
          }
      }
      else{
      cout &lt;&lt; &quot;The file is not accessible to read&quot; &lt;&lt; '\n';
      return 255;
      }
      return 0;
  }
  </code></pre>