Fixed typo in the variable name

This was causing the file not to be written.