Add perror to see what goes wrong