Replace partial contents of file with contents read from other file

Hi,

I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file.
i am able to append the data. but i am seeing junk characters in between. request for help on this.
Please find below sample
File1.txt

Begin
 
End;
after end1;
after end2;

File2.txt

Begin
test1;
test2;
test3;
end

my output file should look like

Begin
test1;
test2;
test3;
end;
after end1;
after end2;

i am able to get the above file but some junk charcters are coming not sure how?

Regards,
Seeki

Please paste your command/script which you are using.

Try...

sed '/Begin/r File2.txt' File1.txt > File3.txt