Now the program returns the error code if an error occurs, or 0 if not.