From: Gregory Brown Date: 2008-07-31T05:16:51+09:00 Subject: Re: Loop behavior not understood (newbie) On Wed, Jul 30, 2008 at 4:07 PM, Thomas Luedeke wrote: > Gregory Brown wrote: > OK, your version seems to work. I'm confused, however, because I don't > see the functional difference between your coding and mine. What was > the error in my coding previously?? Why did it not know how to print to > the intended file?? The primary functional difference is that when you use the block form of File.open(), it closes the file handle for you. Your code was not properly closing the files. It still wrote out a file on my machine, but running under eclipse may be different. If you'd like to try to verify that, add these two lines to the end of your file: detailedModel.close detailedModelModified.close The rest was just making the code more conventional so that others will have an easier time reading it. If you're interested in those, here's what I did: 1. named variables like_this instead of likeThis. 2. used the block form of File to avoid having to manually call File#close 3. Avoided comparing to a boolean. if (something) is the same as if (something == false), unless you want to prevent nil objects from evaluating as false. Everything in Ruby except false and nil are true. 4. Removed the unnecessary 'then' syntax. 5. Shortened the skip line by using the conditional modifier: do_something if some_condition Although it's of course not necessary to write things this way, it is more idiomatic, which makes it easier for people on this list to read it and help you. Try closing the files in the code you provided, and see if that works. If it doesn't, I feel it's a bit of an Eclipse mystery. -greg