How to fix a forloop.last comma error in FAQ schema code?

Hi,

I am using the following code for faq schema. it creates an error in schema markup due to a forloop.last coma (,) on last line

{%- if section.settings.enable_rich_schema -%}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
  {%- for block in section.blocks -%}
  {%- if block.settings.title != blank and block.settings.content != blank  -%}
  {
    "@type": "Question",
    "name": {{ block.settings.title | json }},
    "acceptedAnswer": {
      "@type": "Answer",
      "text": {{ block.settings.content | json }}
    }
}

  {%- unless forloop.index >= 8 -%},{%- endunless -%}
     {%- endif -%}
  {%- endfor -%}
  ]
}
  
</script>
{%- endif -%}