Removed unsafe usage of fopen

- Changed fopen occurnce to use fopen_s instead.
- Readded local variable err, changed type from GLint to int.
- Modified assert for fopen call to work with new fopen_s call.