title: Concatenating lines from a textfile into a paragraph and output it to another file
body: <pre><code>// Assignment7.cpp : Defines the entry point for the console application.
  //
  
  #include &quot;stdafx.h&quot;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
  ifstream infile;
  int index = 0;
  string singleWord;
  
  infile.open(&quot;text.txt&quot;);
  
  
  while (!infile.eof()) //to figure out size of array
  {
      infile &gt;&gt; singleWord;
      index++;
  }
  
  string* strings = new string[index];
  
  infile.close(); //to restart the file at the first word
  infile.open(&quot;text.txt&quot;);
  int count = 0;
  
  while (!infile.eof())      //if not at end of file, continue reading numbers
  {
      infile &gt;&gt; strings[count];
      cout &lt;&lt; strings[count] &lt;&lt; &quot; &quot;;
      count++;
  }
  infile.close();       //close file
  
  ofstream outfile;
  outfile.open(&quot;textfixed.txt&quot;);
  for (int i = 0; i &lt; index; i++) {
      outfile &lt;&lt; strings[i] &lt;&lt; &quot; &quot;;
  
  }
  outfile.close();
  delete[] strings;
  strings = NULL;
  
  return 0;
  }
  </code></pre>
  <p>My program reads a textfile that has 6 sentences setup as such:</p>
  <p>Sentence 1</p>
  <p>Sentence 2</p>
  <p>Sentence 3</p>
  <p>Sentence 4</p>
  <p>Sentence 5</p>
  <p>Sentence 6</p>
  <p>I'm learning how to play with strings, and I want to concatenate the 6 sentences so that in a new file(that my program would write to, called newtext.txt) would have it setup like: Sentence 1. Sentence 2. Sentence 3. Sentence 4. Sentence 5. Sentence 6. So for example, if the textfile contained something like:</p>
  <p>I like to play soccer.</p>
  <p>I enjoy eating apples.</p>
  <p>I am 18 years old.</p>
  <p>I watch baseball sometimes.</p>
  <p>Cooking is a hobby of mine.</p>
  <p>My birthday is in July.</p>
  <p>My program would take the above^ and in a new file write it out as:</p>
  <p>I like to play soccer. I enjoy eating apples. I am 18 years old. I watch baseball sometimes. Cooking is a hobby of mine. My birthday is in July.</p>
  <p>I'm just not quite sure how I go about concatenating each word in order to setup as such. If anyone could point me into the right direction, that'd be appreciated. Thanks.</p>
  <h1>UPDATED OP WITH NEW CODE</h1>
  <p>I don't get any output from the newly updated code, it's supposed to cout() the new paragraph to console but when I run it the CMD is just black</p>