The point is, after you remove the blanks in $name, you then assign a new value to it before doing the write. The output you're seeing is the result of that second assignment, not the result of the substition.
As xmath points out below, you're copying around a lot of stuff, and it's not clear why. You may need to rethink part of your algorithm.
In reply to Re (3): Removing Spaces From A File
by VSarkiss
in thread Removing Spaces From A File
by ellem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |