Thanks you Gary it works now. HOWEVER one last thing I cannot get working. When i run the file from the windows command prompt: "c:/windows/ruby file.rb file" it works perfect but i have a batch file that puts the file into the script and it gives the error Permission Denied Errno::EACCES. I suspect this is due to the file not being closed when it tries to rename it. The .close methods produce the error undefinded method 'close' for Array. This has been taking me hours to try and solve! Anyone know any batch file tricks? Thanks for all the help so far guys. After all my work its turning out windows is giving me the most trouble... -- Posted via http://www.ruby-forum.com/.