- if (modified_image_idx == w->hdr.image_count) {
- /* If no images are modified, a new lookup table does not need
- * to be written. */
+ if (modified_image_idx == w->hdr.image_count && !w->deletion_occurred) {
+ /* If no images have been modified and no images have been
+ * deleted, a new lookup table does not need to be written. */