As mentioned, just condense lines 2 and 3 into one line:

/assist focus

If you do that and your focus/main has the same target, it won't see it as a target change and won't reset the macro.