You are increasing $ioutside the cycle while, so $ithere will always be inside ==0and therefore $i % 4 == 0.
Move $i++;to } // end while.
However, you must also change your condition to $i % 4 == 3, because it $i % 4 == 0evaluates truein the very first iteration ( $i=0) and creates an initial <div>one with only one message.
, :
, 4 , , <div>. , , , a <div> , . .
, $i % 4 == 3 , echo '</div>'; while, if(($i % 4 == 3)&& have_posts()).