fixed a seg fault caused by zerosize output files