import – Is there an integrated way to go through a column / row?

I have a file like this:

        cat data.m
1
2
3
x + y
2 x + 3 y

So it contains lines with numeric numbers or expressions,
which is not at this time pillar per se but on replacement of say x = 1 and y = 2 there is an output column as:

        cat output.m
1
2
3
3
8th

I want to save the entire file to this output file after replacing it x and y, Is there a way to do this? I figured if I could go through the file data.m and doing replacement x and y, Can someone help me?