Added fopen check so we don't open NULL file descriptors.