File write is not the same file read, some encoding issue?

I know I must be doing something wrong but I don’t know what and I can’t
find a solution despite some searching. Here is the code

File.open("#{RELATIVEPATH}/database.db", ‘r’) do |database|
@database = database.read
end
File.open("#{RELATIVEPATH}/database2.db", ‘w’) do |test|
test.puts @database
end

database and database2 have different md5sums so it was not a perfect
copy. I think it must be some encoding difference between how Ruby
interprets the information and how it is stored. The file is an SQLite
database. How can I load it in such a way that it is an exact copy?

ah crap puts got me again :(. Sorry to keep posting issues that I
shortly find the answer to myself, I only like to ask for help when I am
really stuck. Too bad it is too late to delete this.

roob noob wrote in post #1063845:

ah crap puts got me again :(. Sorry to keep posting issues that I
shortly find the answer to myself, I only like to ask for help when I am
really stuck. Too bad it is too late to delete this.

Also, for a completely lossless copy even under Windows, use “rb” and
“wb”