adding the content of a file to another file

hi guys,
I posted a similar question about reading a file and adding its content to another file and i used
sed '/HELLO/r fileB' fileA
however this command adds the content of fileB under the word "HELLO"
what if i need to add the word above "HELLO".
what could i use?
Thanks,

One way:

awk '/HELLO/{print;while((getline < "fileB") > 0)print;next}{print}' "fileA"

Regards

If I want to replace with all occurrences then?

I think it should be like this:

awk '/HELLO/{line=$0;while((getline < "fileB") > 0){print;} print line;next}{print}' "fileA"

(Franklin's version put the content of fileB under HELLO. As well as "r" command in sed)

You're right, I misread the question, it should be:

awk '/HELLO/{while((getline < "fileB") > 0)print}{print}' "fileA"

Regards

thanks guys for ur help

open(FH,"<file1");
while(<FH>){
	if(m/HELLO/){
		$t=$_;;
		open(FH1,"<file2");
		while(<FH1>){
			print;
		}
		close(FH1);
		print $t;
	}
	print;
}
close(FH);