in reply to modifying and overwriting a file

If by 'efficient' you mean 'a one liner' then this is what you are looking for:

perl -pe 'print "_" if $a++;' -i.bak yourfile.txt

Lookup perlrun for more detail on what's going on there.

____________________
Jeremy
I didn't believe in evil until I dated it.