Is ok. But i have TEST(default text to replace in TESTX) in first line, but this TEXT is not replaced in TESTX. But with this thing('replace' method) is working fine.
Test it now and see if it working as you need. (do not modify the code, except the strings you need search and destroy).