1

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. 
sepp2k
  • 363,768
  • 54
  • 674
  • 675
Avdept
  • 2,261
  • 2
  • 26
  • 48

1 Answers1

1

So the problem was in last Rewrite function. Turned out, it made to erase file content, so removing it fixed my program

Avdept
  • 2,261
  • 2
  • 26
  • 48