using feof_unlocked() to test for connectivity.