Fixed looping through array in bash