The issue is that when you double-quote the command substitution in a for loop, the result will not be word split, and the loop will only run once. To avoid this, you need to handle the command substitution in a way that aligns with your intended behavior, such as using read with a while loop.