Use err.h error handling instead of perror.