Update p7v.c

Fixes for : 
Issue #1. On error during initialization, error is handled before exiting program.
Issue #2. NULL pointer check added before calling fclose