fixed seg fault in file output