Not sure you need that custom for loop. Also, an alternative to using the modulo operator is to reset the counter. Take a look at this as an example:
// Init the counter.
$i = 0;
// Begin activity loop here.
// Increment the counter by 1.
$i = ++$i;
// Check if we're in the 8th iteration.
if ( 8 === $i ) {
// Output ad code here.
// Reset the counter.
$i = 0;
}
// End activity loop here.