Added free() for malloc'ated fname var