You change the value of $line, then you print out that it happened. But you never actually make any changes to the file (i.e. changing the value of $line does not change that line in the file, you have to write it back out).
BTW you might want to take a look at File::Find, and maybe $^I in perlvar (or the -i switch).