That breplace will just replace a line feed char with another, this replaces a line feed with a carriage return & line feed but it does indeed fail if char 10 is at the end of the binary variable, qwerty's method seems ideal