divisible by strange issue
You have some other bug somewhere else. Check the code pulling out entry details to be sure that it doesn't modify loop or the list you are looping on, or the current item.

This code works:

{% for item in (1..10) %}
  {% if loop.first %} [ {% endif %}
  {{ item }}
  {% if loop.index is divisible by(4) and not loop.last %}
    ] [
  {% endif %}
  {% if loop.last %} ] {% endif %}
{% endfor %}


And outputs this:

[ 1 2 3 4 ] [ 5 6 7 8 ] [ 9 10 ]


You can simplify it a bit:

{% for item in (1..10) %}
  {% if loop.first %} [ {% endif %}
  {{ item }}
  {% if loop.index is divisible by(4) or loop.last %}
    ] [
  {% endif %}
{% endfor %}


You also can use the batch filter, which I think makes things slightly clearer:

{% for b in (1..10) | batch(4) %}
  [
    {% for item in b %}
      {{ item }}
    {% endfor %}
  ]
{% endfor %}