Fixed the fopen_s to a safe one