Error check in main now exits program after displaying error message