changed encoding to replace rather than ignore