Declare "pos" as local variable

This variable is set in the `for` loop on the next line. We should
declare it locally to avoid setting a global variable.
Removed unused variable