Undefined offset, CCK field
You can try to check if array element exist before assigment, and only if so, assign it, an this way avoid undefined offset:

  if (isset($node-&gt;field_addendum['und'][$i]['filename'])) {
     $variable1 = $node-&gt;field_addendum['und'][$i]['filename'];
    }