Blank rows in Doc Merge PDF template

We have a template that used this logic successfully within wDocs. Nevertheless, during the transition to Doc merge, it now fills in all the product lines on the quote. I've wrote a new simple code that only populates the products if they meet specific criteria; however, I'm encountering persistent blank rows that have proven quite challenging to eliminate.
Any suggestions on how to eliminate the blank rows would be greatly appreciated!
Thanks in advance

{#products filter='Accessories'}{ capitalize='true'}  {category_name} {/products}

Fig 1: WDocs code

{#products sort='cattest_c:desc'}
{if cattest_c=='Accessories'} {}
{elseif cattest_c!='Accessories'}

Fig 2:Doc merge new code

Fig 3: Doc merge PDF