[fix] Two resource leaks fixed
Don't do extra unneeded comparison
[fix] Restore ostream format
[fix] Check return function values (open, seek...)