Use perror instead of fprintf