如何将下面的简单的文件读写代码改成同样功能的流的读写?主要考虑到大的日志LOG文件还采用一行一行的读写效率太低了。谢谢procedure TLA.Execute;
var MyText:TextFile;
begin
  FreeOnTerminate:=True;
  
  CurrentSize:=0;
  Lines:=0;
  LastFPos:=0;
  intMisc:=0;
  intHTM:=0;
  intErr:=0;  if frmMain.OpenDialog.Execute then
    begin
    
      frmMain.lblFileName.Caption:=frmMain.OpenDialog.FileName;      AssignFile(F,frmMain.OpenDialog.FileName);
      Reset(F);
      Try
        FSize:=FileSize(F);  {获取文件大小}
        frmMain.lblFSize.Caption:=IntToStr(FSize);
      Finally
        CloseFile(F);
      End;      FSize:=FSize div 100;
      if FSize=0 then FSize:=1;      AssignFile(MyText,frmMain.OpenDialog.FileName);
      Reset(MyText);      While Not EOF(MyText) do {文件没有结束继续读文件}
        begin
          If Terminated Then Break; {如果线程被终止,则退出线程}          ReadLn(MyText, S);  {从日志文件读数据}          if (PosEx('1.1" 404',S,50)<>0) or (PosEx('1.1" 800',S,50)<>0) then
            begin
              Inc(intERR);
              //Append(logerr);
              //WriteLn(logerr,S);
            end
          else if (PosEx('.htm',S,50)<>0) or (PosEx('.html',S,50)<>0) or
                  (PosEx('.asp',S,50)<>0) or (PosEx('.aspx',S,50)<>0) or
                  (PosEx('.jsp',S,50)<>0) or (PosEx('.js',S,50)<>0)   or
                  (PosEx('/ HTTP/1.1',S,50)<>0) then
            begin
              Inc(intHTM);
              //Append(logpage);
              //WriteLn(logpage,S);
            end
          else
            begin
              Inc(intMisc);
              //Append(logmisc);
              //WriteLn(logmisc,S);
            end;          Inc(Lines);          CurrentSize:=CurrentSize+Length(S)+2;
          //frmMain.cxMemo1.Lines.Add(S);
          FPos:=CurrentSize div FSize;          if FPos<>LastFPos then
          begin
            frmMain.ProgressBar.Position:=FPos;
            LastFPos:=FPos;
            Synchronize(GiveAnswer);          end;               end;
    end;
    CloseFile(MyText);
    //CloseFile(logerr);
    //CloseFile(logpage);
    //CloseFile(logmisc);
end;===============================================================THX!
我现在主要不知道怎么循环读这个流,怎么判断文件结束?!流的写法取行数据比较奇怪,如果按流这样读我怎么像以前读文件那样判断我每行的东西呢????????????