Reading through an array
- You're not iterating through an array.
$profilesToRemove
is not an array, it's just some lines of text. -
${(f)profilesToRemove}
is very strange. Perhaps you meant$profilesToRemove
? -
for
needs to begin on a new line (or;
separated from the previous statement).