Changed some occurrences of fopen to fopen_s (if Windows)