Function causing the loop display posting more (empty)

Is this happening if you remove the pre_get_posts hook?

Either way, you can try wrapping the code in a conditional.

while (have_posts() ) : the_post(); 
if ( 0 < intval( the_ID() ) {
...
}
endwhile;

This is not quite as good as limiting the number of records returned by the query but it doesn’t hurt to validate as you go along anyways.