Update p7v.c

1. On error during initialization, error should be handled before exiting program.
2. NULL pointer check added before calling fclose