Better handling of fopen() errors