You mean unset($f) ?

We need to clean it for each iteration otherwise sometimes it may contain values from previous items. E.g. when file1 has snippet but file2 doesn't. If we don't clean the "$f" file2 will have snippet field from file1.