rstrip didn't work as expected, changed to replace