If a file is opened to append to it, the file descriptor sits on the end of the file waiting for your data to be appended. (At least I think this is the case, I may be wrong.)
You'll have to seek
(perldoc -f seek) back to the beginning of the file - but you really don't want to do this.
I strongly recommend not writing on the same data you're reading from - open the file for reading, put it into some convenient data structure - wether array or a scalar depends on what your're going to do - change it in there and write afterwards the entire text.
make an array to add stuff linewise:
@all_lines = <$fh_read>;
or put all in one scalar (sometimes _very_ useful, especially with reg ex flags like s///sm <--):
local $/; #enable slurp mode - see perldoc perlvar for details
$all_lines = <$fh_read>;
Now use your loop, change the data and _afterwards_ write it to the file - override brutally it if you're confident
or copy first and write a new one.