Fixed the for loop in the bash script