My first thought was that you have to pass the file object to the snippet:
<?= snippet($file->type(), ['file' => $file]) ?>
But if the variable was undefined, the error message should be that the variable is undefined and not that the variable is a string.
But I actually wanted you to write
<?php dump($file) ?>
in the loop.