initialize type to '' for each loop iteration

Using an old value from a previous loop for type could cause confusion and make the script throw exceptions