title: using fstream within linux
body: <p>I think i have a beginners question.</p>
  
  <p>I try to read a file line by line.</p>
  
  <p>The file is in /home/myhomedir and called text.txt . 
  The content of the file is</p>
  
  <pre><code>1
  2
  3
  4
  </code></pre>
  
  <p>The file has access right for everyone to read and write.</p>
  
  <p>I wanted: open the file and read it one line after another.</p>
  
  <p>So I tried: </p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt; 
  
  using namespace std;
  
  int main(int argc, char** argv) 
  {
      try
      {
          ifstream myfile ;
          myfile.open("/home/myhomedir/text.txt", ios::in);
          if(myfile.is_open())
          {
              string line;
  
              while (getline(myfile, line)) {
                 // do nothing, just get a line
                 // *
              }
          }
      }
      catch(int ex)
      {
      }
  
      return 0;
  }
  </code></pre>
  
  <p>The place marked with * is reached (used the debug feature of netbeans). however line is empty and loop seemed to be entered only once.</p>
  
  <p>Like if an empty file is opened.</p>
  
  <p>What am I doing wrong?</p>