You are deleting the filename initialization, and the variable is used later. Shouldn't be deleted.