I humbly refer you to my previous reply which solves namelessjoe's problem. It works because the @goodlines array is empty on those occasions where the blank lines are output.
In short, there's no point trying to remove some entries from the array which are themselves empty or just whitespace because there are no entries in the array. The thread title is a bit misleading in that respect. I initially started down the route which you and stevieb took, but a quick test determined that the output would not match what was reported in the original node. Hence the conclusion/supposition that the "bad" lines were ones where the array was entirely empty.
Hope this helps and that it avoids anybody spending more time on blind alleys.