Change
bash
readlink -f $line > a.txt
to
bash
readlink -f "$line" >> a.txt
The >> appends to a file or creates the file if it doesn't exist.
The > overwrites the file if it exists or creates it if it doesn't exist.