title: Ubuntu - issue with opening a .txt file from terminal
body: <p>I have built a .cpp program in order to write some content to a .txt file created within the .cpp file.</p>
  
  <p>I manage to write the desired content, however, when I am trying to open the created file from terminal, it says that it cannot find it although it is there.</p>
  
  <p>When I try to open it with <code>vi</code> or <code>nano</code> it's content it's empty. It is like creating a new file.</p>
  
  <p>However, when I open it outside terminal, I can see its content as I wanted.</p>
  
  <p>What could be the problem and how can I fix this situation?</p>
  
  <p>Bellow, I have added the code.</p>
  
  <p>The problem is with the <code>system(buffer)</code> command. I receive the following error: <code>sh: cannot open video2.txt: No such file</code>. I have tried to opened the files from command prompt and I get the above described situation.</p>
  
  <pre><code>int main(int argc,char* argv[])
  {
  
  fstream RawStipFile;
  RawStipFile.open(strcat(argv[1],".txt"));
  string line;
  
  if (RawStipFile.is_open())
  {
  
      getline(RawStipFile, line);
      int i = 0;
      ofstream OutVideoStip;
      ofstream VideoList;
      VideoList.open("VideoList.txt");
      while ( RawStipFile.good() )
      {
  
          getline (RawStipFile,line);
          char* l;
          l = (char*) malloc(sizeof(char));
          l[0]=line[0];
          //cout&lt;&lt;line[0]&lt;&lt;endl;
          if (line[0]==35)
          {
  
              if (OutVideoStip.is_open())
              {
                  OutVideoStip.close();
              }
              i++;
                          //char* base;
                          //base = (char*) malloc(1000*sizeof(char));
                          //sprintf(base, "%d", i);
              char* b;
              b = &amp;line[1];
              VideoList&lt;&lt;b&lt;&lt;endl;
              OutVideoStip.open(strcat(b, ".txt"));
  
  
          }
  
          else
          {
  
              OutVideoStip &lt;&lt; line &lt;&lt; endl;
  
          }
  
  
      }
  
      OutVideoStip.close();
      RawStipFile.close();
      VideoList.close();
  }
  
  else
  {
      cout &lt;&lt; "Unable to open file \n";
  }
  
  fstream VideoNames;
  VideoNames.open("VideoList.txt", fstream::in);
  
  if (VideoNames.is_open())
  {
      while ( VideoNames.good() )
      {
          getline(VideoNames, line);
          line=line.substr(1,line.length());
          if (line.compare(""))
          {
              string initial = "./txt2mat&lt;";
              initial.append(line);
              initial.append(".txt&gt;");
              initial.append(line);
              initial.append(".dat");
              cout&lt;&lt;initial&lt;&lt;endl;
              const  char* buffer;
              buffer = initial.c_str();
              system(buffer);
          }
      }
  }
  else
  {
      cout&lt;&lt;"Unable to open file. \n";
  }
  
  VideoNames.close();
  
  return 0;
  }
  </code></pre>