I tested it in my environment and found the same expected behavior as yours. Unfortunately, this appears to be a limitation from the transport rules. rules have no way of knowing where it starts and ends, so it keeps it at the end as expected.
If you're thinking of other solutions, you can take a look at this, I see some ideas here.
(Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.)
Regards
Shafan
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.