Read a file and create egrep variable

I want to create a egrep variable from a file.
For example:

string=`cat query.txt`
cat myfile.txt | egrep "$string"

The string variable file has a list of one or multiple lines
So the end result of:

cat myfile.txt | egrep "$string"

would be:

cat myfile.txt | egrep "test1|test20|test33"

I can not figure out how to read the file line by line and put a | between all but the last line and if the file only has one entry, to not put any |

As a hint, perhaps:

$ cat file1
a
b
c
$ paste -sd\| file1
a|b|c

You have a lot of useless uses of cat there.

cat file | grep ...

can easily be done using

grep ... file

Thank you Scottn, the paste command works for me.