fixed array index problem when --tmpdir is specified