Code:
done < /tmp/coa1.txt > /tmp/coa2.txt
Each time this line executes, it overwrites coa2.txt, so you end up with only the last line. What you want to do is append to that file, not overwrite it. Change it to this:
Code:
done < /tmp/coa1.txt >> /tmp/coa2.txt