getting multiple line data as marked entries of header table ?

I have created one Boolean field in sales invoice header when i mark this field and trying to fetch data as per header from line table. It is not fetching as per header just header first line data getting in all multiple row following is code on page onaftergetrecords()

SalesInvoiceLine.SETRANGE(“Document No.”,“No.”);
//SalesInvoiceLine.SETFILTER(“EDI check”,’%1’,TRUE);//filter to checked entries

IF SalesInvoiceLine.“Sell-to Customer No.”<>’’ THEN
IF SalesInvoiceLine.FINDSET THEN REPEAT

“PartNo.” := SalesInvoiceLine.“No.”;
HSNCODE := SalesInvoiceLine.“HSN/SAC Code”;
Qty := Qty + SalesInvoiceLine.Quantity;
Rate:= SalesInvoiceLine.“Unit Price”;
TotalGSTAmt:= TotalGSTAmt + SalesInvoiceLine.“Total GST Amount”;
PackingDetails := SalesInvoiceLine.“Pack.Details”;

UNTIL SalesInvoiceLine.NEXT = 0;

on page action i want this data as per header and line data .i am outputting this data in the text file

txtTempFilename:=FileManagement.ServerTempFileName(‘Encript.txt’);
File1.CREATE(txtTempFilename);
File1.CREATEOUTSTREAM(Outstream1);
Rec.RESET;
Rec.SETFILTER(“EDI Check”,’%1’,TRUE);
SalesInvoiceLine.SETFILTER(“EDI check”,’%1’,TRUE);
IF Rec.FIND(’-’) THEN
REPEAT
Outstream1.WRITETEXT(FORMAT(Plant)+’,’+ OurVendorCode +’,’+ CompGSTNo+’,’+ HSNCODE+’,’+FORMAT(0)+’,’+“PartNo.” +’,’+“External Document No.”+’,’+FORMAT(“Line Item No”)+
‘,’+“No.” +’,’+FORMAT(PostingDate)+’,’+DELCHR(FORMAT(Qty,0,’<Decimal,3>’),’=’,’,’)+’,’+DELCHR(FORMAT(Rate,0,’<Decimal,3>’),’=’,’,’)+
‘,’+DELCHR(FORMAT(Amount,0,’<Decimal,3>’),’=’,’,’)+’,’+FORMAT(0)+’,’+FORMAT(0)+’,’+FORMAT(0)+
‘,’+DELCHR(FORMAT(Amount,0,’<Decimal,3>’),’=’,’,’)+’,’+FORMAT(0)+’,’+DELCHR(FORMAT(Amount,0,’<Decimal,3>’),’=’,’,’)+
‘,’+DELCHR(FORMAT(vCGSTRate,0,’<Decimal,3>’),’=’,’,’)+’,’+DELCHR(FORMAT(vCGSTAmount,0,’<Decimal,3>’),’=’,’,’)+
‘,’+DELCHR(FORMAT(vSGSTRate,0,’<Decimal,3>’),’=’,’,’)+’,’+DELCHR(FORMAT(vSGSTAmount,0,’<Decimal,3>’),’=’,’,’)+
‘,’+DELCHR(FORMAT(vIGSTRate,0,’<Decimal,0>’),’=’,’,’)+’,’+DELCHR(FORMAT(vIGSTAmount,0,’<Decimal,0>’),’=’,’,’)+’,’+FORMAT(0)+
‘,’+FORMAT(0)+’,’+DELCHR(FORMAT(“Amount to Customer”,0,’<Decimal,3>’),’=’,’,’)+’,’+’,’+’,’+“Vehicle No.”+’,’+ PackingDetails +’,’);

Outstream1.WRITETEXT();
UNTIL Rec.NEXT=0;
File1.CLOSE;
MESSAGE(‘EDI File Created’);
FileManagement.DownloadToFile(txtTempFilename,‘C:\NAV EDI\Encript.txt’);