Fixed variable name bug.
Appended error output with exit code.