Thanks for your responses. What I was doing was reading in some data from a binary file, this data need to be printed in an xml document. I have now used Base64.encode64(rawdata) and I am using this to write to the xml file. It wasn't working at first, maybe because I opened the file in binary mode. Thanks, Jim. -- Posted via http://www.ruby-forum.com/.