ACF iterating past the while-loop, defining a max number to loop

If I compare the counter to five instead of the input (****), then it evaluates perfectly. Thanks to Milo for the help.

<?php if( have_rows('program_skills') ) : 
    while( have_rows('program_skills') ) : the_row(); ?>

        <div class="skills-wrapper">
            <div class="col-xs-6">
                <p><?php the_sub_field('heading'); ?></p>
            </div>
            <div class="col-xs-6">
                <div class="skills-graph">
                    <ul>
                        ****<?php for($i=1; $i<=5; $i+=1)
                            if( $i <= get_sub_field('rating') ) {
                                echo '<li class="graph empty ' . 'fill-' . $i . '"></li>';
                            } else {
                                echo '<li class="graph empty"></li>'; 
                            } 
                         ?>
                    </ul>
                </div>
            </div>
        </div>

    <?php endwhile;
endif;?>