I would either remove this test, or initialise fname with NULL.