I'm not testing fopen - if I get an invalid file descriptor then the result of the following calls will trigger a failed test anyway.

And to be honest I just copied it from the codebase I was testing.