title: displaying a line vs word in c++
body: <p>I am working on my assignment and I have come across an error that i would like to understand (assuming this is an error and not just me overthinking the question).  My current output is giving me one word at a time whereas i would like to display a line at a time. Here is my code:</p>
  
  <pre><code>/*
  ///////////////////////////////////////////////////////////////////////////
  Write a program that creates an array of 100 string objects. Fill the
  array by having your program open a (text) file and read one line of the
  file into each string until you have filled the array. Display the array
  using the format “line #: &lt;string&gt;,” where # is the actual line number
  (you can use the array counter for this value) and &lt;string&gt; is the stored
  string.
  ///////////////////////////////////////////////////////////////////////////
  */
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main ()
  {
      string story[100];  // create array of 100 string objects
      string filename = "testfile.txt";
      ifstream file(filename); //open file
  
      // go through array till index 100
      for( int x=0; x&lt;= 100; x++)
      {
         file &gt;&gt; story[x]; // get line and store into array
         cout &lt;&lt; "Line " &lt;&lt; x &lt;&lt; ":" &lt;&lt; story[x] &lt;&lt; endl; // display
      }
  
      return 0;
  }
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre><code>I 
  ordered
  this
  sandwich
  once
  with
  paper .....
  </code></pre>
  
  <p>whereas i want this:</p>
  
  <pre><code>I ordered this sandwich once with paper-thin carrots in it.
  I can’t remember what else. 
  I tried to recreate it.
  </code></pre>