How to read and write files?

Why are you reading one file and then writing it to another?

Why don't you just copy it? http://is.gd/gNve

And if file operations doesn't work, open up console and try it there.
You will see if it was successful, because irb will show true/false.
If it's false, then check if your directories have rights to be
writed.