in reply to binary search/replace
Did you try throwing in some binmodes for all the input and output files? It's easy to forget.