// how to use modulus to track every fourth line
int everyFourthLine = 0;

for ( String x : someCollection )
   {
   if ( everyFourthLine++ % 4 == 0 )
      {
      doSomethingSpecial();
      }
   out.println( x );
   }