Removed a stupid error

$key didn't exist as it was outside the loop