为什么我使用getline读取文件但没有读完就不运行了

void readText4(string file,string file2)
{
    ifstream infile;
    string cfgtemp;
    ofstream clog;
    infile.open(file,ios::in);
    clog.open(file2,ios::app);
    char ch[1001]={0};
    int i=0,j=0;
    

```c++

```while(infile.getline(ch,1000))
{

    /*j++;*/
    for(i=0;i<1000;i++)
    {
        /*if(ch[i]=='\n')
        j++;*/
        if(ch[i]=='?'&&ch[i+1]=='u'&&ch[i+2]=='='&&ch[i+3]!='b')
        {   
            int a=1;
            /*cout<<'['<<j<<']';*/
            while(ch[i+a]!='@'&&ch[i+a]!='&'&&ch[a+i]!='%')
            {
                clog<<ch[i+a];
                a++;
                
            }
            clog<<'\n';
            //cout<<ch[i+a];    
            //cout<<endl;
            
        }
        
    }
    /*if(j>1000000)
    {
        cout<<j;break;
    }*/
    
}/*cout<<j;*/
  //cout<<j;
  infile.close();
  clog.close();

}

```c++

while语句没有运行完就不运行了

infile.open(file,ios::in);这句之后,你要判断open是否成功了。如果open失败,while自然不好使