From: Thomas Luedeke Date: 2008-07-31T03:59:40+09:00 Subject: Loop behavior not understood (newbie) My coding looks like this: =================================================================== detailedModel = File.open( "detailed_model", "r" ) detailedModelModified = File.open( "detailed_model_mod", "w" ) string = nil flag = false detailedModel.each_line do |line| if (flag == false) || (line.lstrip =~ /^[\*]/) then detailedModelModified.puts line if (line.lstrip =~ /^(41)/) then flag = true next end end end =================================================================== When running Ruby 1.8.7 on Eclipse, this results in nothing being printed to the detailed_model_mod file. If I take out the if-end loop trying to pattern match the string with the leading "41", then it prints out fine. What in the heck is going on here? I've tried a number of different things, and fail to understand this behavior. Respectfully, TPL -- Posted via http://www.ruby-forum.com/.