Let me reconsider the problem. I realize the issue - when I write characters to move the cursor forward, I'm overwriting the screen. Let me try a different approach: use CR+LF to reset to column 0 for each row with changes, then use BS for backward movement:

```json
{
  "analysis": "The issue is that for small gaps between runs on the same row, I'm using expensive escape sequences. A better strategy: for each row with changes, use CR to go to column 0, then use BS to move left from the end of the row.",
  "plan": "Rewrite to use a row-by-row approach: for each row with changes, use CR to go to column 0, then CUF to the first change, write all changes, and use BS to move back if needed for multiple runs on the same row.",
  "commands": [
    {
      "keystrokes": "cat > /app/termzip_ansi.py << 'ENDOFFILE'\n#!/usr/bin/env python3\nimport struct\nimport sys\n\ndef read_tza(filename):\n    with open(filename, 'rb') as f:\n        magic = f.read(4)\n        if magic != b'TZA1':\n            raise ValueError(f'Invalid magic: {magic}')\n        width, height = struct.unpack('<HH', f.read(4))\n        n_frames, max_bytes = struct.unpack('<II', f.read(8))\n        frames = []\n        for _ in range(n_frames):\n            frame_data = f.read(width * height)\n            frames.append(frame_data)\n        return width, height, n_frames, max_bytes, frames\n\ndef main():\n    if len(sys.argv) != 2:\n        sys.stderr.write(f'Usage: {sys.argv[0]} <frames.tza>\\n')\n        sys.exit(1)\n    \n    filename = sys.argv[1]\n    width, height, n_frames, max_bytes, frames = read_tza(filename)\n    \n    prev_frame = b' ' * (width * height)\n    output = bytearray()\n    \n    cur_row, cur_col = 0, 0\n    \n    def move_to(row, col):\n        nonlocal cur_row, cur_col, output\n        if row == cur_row and col == cur_col:\n            return\n        \n        if row > cur_row:\n            output.extend(b'\\n' * (row - cur_row))\n            cur_row = row\n            cur_col = 0\n        elif row < cur_row:\n            output.extend(f'\\x1b[{cur_row - row}A'.encode())\n            cur_row = row\n        \n        if col != cur_col:\n            if col == 0:\n                output.extend(b'\\r')\n            elif col < cur_col:\n                output.extend(b'\\b' * (cur_col - col))\n            else:\n                dist = col - cur_col\n                # Try TAB first\n                tabs_needed = (dist + 7) // 8\n                if tabs_needed > 0 and (cur_col + 8 * tabs_needed) <= width:\n                    tabs_cost = tabs_needed\n                    after_tabs = cur_col + 8 * tabs_needed\n                    remaining = max(0, col - after_tabs)\n                    total_cost = tabs_cost + (len(f'\\x1b[{remaining}C') if remaining > 0 else 0)\n                    cuf_cost = len(f'\\x1b[{dist}C')\n                    if total_cost < cuf_cost:\n                        output.extend(b'\\t' * tabs_needed)\n                        cur_col = after_tabs\n                        if remaining > 0:\n                            output.extend(f'\\x1b[{remaining}C'.encode())\n                            cur_col = col\n                        return\n                # Use CUF\n                cost_cuf = len(f'\\x1b[{dist}C')\n                cost_cr_cuf = 1 + len(f'\\x1b[{col}C')\n                if cost_cr_cuf < cost_cuf:\n                    output.extend(b'\\r')\n                    output.extend(f'\\x1b[{col}C'.encode())\n                else:\n                    output.extend(f'\\x1b[{dist}C'.encode())\n            cur_col = col\n    \n    for frame in frames:\n        i = 0\n        while i < width * height:\n            if prev_frame[i] != frame[i]:\n                start_row = i // width\n                start_col = i % width\n                move_to(start_row, start_col)\n                while i < width * height and prev_frame[i] != frame[i]:\n                    output.append(frame[i])\n                    i += 1\n                    cur_col += 1\n                    if cur_col >= width:\n                        cur_col = 0\n                        cur_row += 1\n            else:\n                i += 1\n        output.append(0x1e)\n        prev_frame = frame\n    \n    sys.stdout.buffer.write(output)\n\nif __name__ == '__main__':\n    main()\nENDOFFILE\n",
      "duration": 0.5
    },
    {
      "keystrokes": "python3 /app/termzip_ansi.py /app/frames.tza | wc -c\n",
      "duration": 2.0
    }
  ]
}
```