Var tmpFile: String; tmpList: TStringList; Const ctOutputPath = 'C:\Test\Out_Csv\'; // Must end with a \ ctRow1 = '"000000","","","","","","OUTNAME",""'; ctRow2 = '"999999","","","","","","",""'; Begin (* I need to add a record to the start of each file with the same structure, the fields can be empty but I do need to populate 2 of the fields The sequence fields needs to be 000000 Outname fields needs to be the name of the data file I then need to add a record at the end of the file but only 1 field needs to be populated Sequence = 999999 // "SEQUENCE","CARDNAME","MEM_TYPE","MEMNO","EXPDATE","ASTERIX","OUTNAME","TOTALRECS" // "000001","Mrs AB Sample","Individual Member","999999","Jan-26","*","MPP_Card_Proofs","235" *) psExitCode:= 0; tmpFile := psFilePath + psFileName; // ... add your code here tmpList := TStringList.Create; Try Try tmpList.LoadFromFile(tmpFile); If tmpList.Count > 0 Then Begin tmpList.Insert(1, psStringReplace(ctRow1, 'OUTNAME', psFileName)); tmpList.Append(ctRow2); // Save Try tmpList.SaveToFile(ctOutputPath + psFileName); // Result Successful psExitCode := 1; Except psLogWrite(1, '', 'SaveToFile Error: ' + ctOutputPath + psFileName); End; End Else psLogWrite(1, '', 'Found empty file: ' + tmpFile); Except psLogWrite(1, '', 'LoadFromFile Error: ' + tmpFile); End; Finally tmpList.Free; End; End.