Check return value for fopen() which could fail if there's no space left on the device