title: Ruby will open file but not write to it?
body: <p>I'm trying to create a basic ruby scraper that will grab all words 8 letters or longer from html source code.  Then it saves these in a file corresponding to the first character of the word.  Seems simple huh?</p>
  
  <pre><code>    re = /\w{8,}/
      cre = /[a-z0-9]/
      a = b.html    #This grabs the html from the browser
      matchx = a.scan(re)
      matchx.each do |xx|
          word = xx.to_s.downcase.chomp
          fchar = word[0].chr
  
          if (fchar.match(cre)) #Not sure if I need this
              @pcount += 1
              fname = @WordsFName+fchar   #@WordsFName is a prefix
              tmpF = File.open(fname,"a+")
  
              #Check for duplicates, if not write to file
              exists = File.readlines(fname).any? { |li| li[word] }
              if (!exists)                    
                  tmpF.write(word+"\n")
                  print word 
                  @wcount += 1
              end
          end
  
      end
  </code></pre>
  
  <p>Ruby successfully grabs all the words, gets the first character, and opens all the necessary files, but fails to write to it.  Also, the print method prints all words including duplicates, but inspecting the any? method on irb gave no problems..</p>