end of line
<p>I am currently working on a program that read each line from a file and extract the word from the line using specific delimiter.</p>

<p>So basically my code looks like this</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;

using namespace std;

int main(int argv, char **argc)
{
  ifstream fin(argc[1]);
  char delimiter[] = "|,.\n ";
  string sentence;

  while (getline(fin,sentence)) {
     int pos;
     pos = sentence.find_first_of(delimiter);
     while (pos != string::npos) {
        if (pos &gt; 0) {
           cout &lt;&lt; sentence.substr(0,pos) &lt;&lt; endl;
        }
          sentence =sentence.substr(pos+1);
          pos = sentence.find_first_of(delimiter);
      }
  }
}
</code></pre>

<p>However my code didnot read the last word in the line. For example, my file looks like this.
hello world</p>

<p>the output from the program is only the word "hello" but not "world" . I have use '\n' as the delimiter but why didnot it works?.</p>

<p>Any hint would be appreciated.</p>
