Remove trailing 0s from end of output array