write_idx function

Write an array into an IDX file