fopen with checks