...                       },
                    }
                    out.write(json.dumps(record, ensure_ascii=False) + "\n")
                    flush_fsync(out)

                    # CSV-safe: immer quoten
                    err_csv = ""
                    idx.write(f"\"{rel}\",\"{block_id}\",1,\"{err_csv}\",{attempt},{round(duration,3)},{len(text_attempt)},{curr_num_predict}\n")
          ...