Вы можете создать новый файл и скопировать все строки, кроме той, которую хотите заменить. Как это:
var musicfile: TextFile;
newfile: TextFile;
line: string[100]; // long enough to hold the longest line in the file
i: word; // counter for the lines
AssignFile(musicfile, 'AlbumList.dat');
AssignFile(newfile, 'AlbumList(1).dat'); // create new file
Reset(musicfile);
Rewrite(newfile); // open the new file for writing
i := 0 // we are at the 1st (index from zero) line
while not eof(musicfile) do begin
readln(musicfile, line); // read the line into a variable
if (i = 4) then // if we are at the 5th line, replace line
writeln(newfile, 'The string which should replace the 5th line')
else // just copy the line
writeln(newfile, line);
i := i + 1;
end;
Close(musicfile);
Close(newfile);