Fix sporadic truncation of output files