The specifics are quite important - next time copy and paste the _entire_ error output.

'cam' is out of scope - you declare it within the curly brackets of the for loop.