It will work but the potential problem is that with relative distances and only a Z switch you may not have room to raise 25mm.

These are the sort of problem that are caused by using only a subset of proper Gcode. In real Gcode you can do conditional things and make more complex decisions.