So, i've faced this task. I wrote code, but somehow instead of putting content of file into another file2, it simply erase content of file2. What am i doing wrong?
Program Lesson9_Program2;
Var FName, Fname2, Txt, Txt2 : String;
UserFile, UserFile2 : Text;
Begin
FName := 'Textfile';
Assign(UserFile,'E:\text.txt'); {assign a text file}
Assign(UserFile2,'E:\text2.txt');
Reset(UserFile);
Reset(UserFile2);
readln(UserFile2, Txt);
readln(UserFile, Txt2);
Close(UserFile2);
Close(UserFile);
Rewrite(UserFile);
WriteLn(UserFile, Txt);
WriteLn(UserFIle, Txt2);
Close(UserFile);
Rewrite(UserFile);
End.