Revert "No more infinite loops due to invalid file pointers"

This reverts commit 0d1e980f2185b2f674bbaf018051369c53e14f98.
Revert 0d1e980..40571d9

This rolls back to commit 0d1e980f2185b2f674bbaf018051369c53e14f98.