Let the caller close fp. Properly check for errors when calling subroutines. This was Coverity CID 1269995.