Controlla il puntatore restituito da fopen:
codice:
$ man fopen
...
RETURN VALUES
     Upon successful completion fopen(), fdopen(), and freopen() return a FILE pointer.
 Otherwise, NULL is returned and the global variable errno is set to indicate the error.
...