Abnormal Output from program
<p>I have a program that should print out 2 lists like the one bellow, basically the same list but backwards, however it works the first time but then it prints some weird output which I Will show bellow as well.</p>

<pre><code>0123456789
9876543210
</code></pre>

<p>however the actual output I get from my program is this: </p>

<p><img src="http://i.stack.imgur.com/O6jJ8.png" alt="sample Output"></p>

<p>Can anyone tell me what is wrong with my code please, I am not sure why I am getting this output.</p>

<pre><code>void createFile(){
  ofstream myfile;
  myfile.open ("TEST1.txt");
  for(int x = 0; x &lt; 10; x++){
   myfile &lt;&lt; x &lt;&lt; "\n";
  }
  myfile.close();
}

void popArray(int array1[]){
  ifstream infile("TEST1.txt");

  int x;
  while(infile &gt;&gt; array1[x]){
    cout &lt;&lt; array1[x];
  }

}

void reverseList(int array2[]){
  for(int x = 9; x &gt; -1; x--){
    cout &lt;&lt; setw(2) &lt;&lt; array2[x];
  }
} 

void checkLists(int array1[], int array2[], int sizeOfArray){
  for(int x = array1[1]; x &lt; sizeOfArray; x++){
    for(int y = array2[1]; x &lt; sizeOfArray; x++){
        if(x == y)
            cout &lt;&lt; "Palindrome" &lt;&lt; endl;
        else{
            cout &lt;&lt; "Not" &lt;&lt; endl;
        }
    }
  }

} 


int main()
{
  int array1[10];
  int array2[10];

  createFile();
  popArray(array1);

  cout &lt;&lt; "\n";

  reverseList(array1);

  cout &lt;&lt; "\n";
  checkLists(array1, array2, 10);
}
</code></pre>
