replace checking badbit with failbit in iostream ops