fixes

- correct counting replacements in replace_linear
- catch IOError from shutil