Prevent segfault when input file could not be opened

Hat tip @peterjc, cf #212.  (This is clearer than the previous attempt;
the two are mostly equivalent as in==NULL approx.iff h==NULL.)