Your pre-commit script modifies the working tree copy of the file, but not the version in the index. The latter one is what actually gets committed.
You need to git add
the file after modifying it. But, doing this will mean that all changes to that file will be included in every commit even if you're trying to commit just some changes from the working tree.