add exit in freopen and open on error condition