title: Having trouble with str.find()
body: <p>I'm trying to use the str.find() and it keeps raising an error, what am I doing wrong?</p>
  
  <pre><code>import codecs
  
      def countLOC(inFile):
          """ Receives a file and then returns the amount
              of actual lines of code by not counting commented
              or blank lines """
  
          LOC = 0  
          for line in inFile:
              if line.isspace():
                  continue
              comment = line.find('#')
              if comment &gt; 0:
                  for letter in range(comment):
                      if not letter.whitespace:
                          LOC += 1
                          break            
          return LOC
  
      if __name__ == "__main__":
          while True:
              file_loc = input("Enter the file name: ").strip()
              try:
                  source = codecs.open(file_loc)
              except:
                  print ("**Invalid filename**")
              else:
                  break 
          LOC_count = countLOC(source)
  
          print ("\nThere were {0} lines of code in {1}".format(LOC_count,source.name))
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>  File "C:\Users\Justen-san\Documents\Eclipse Workspace\countLOC\src\root\nested\linesOfCode.py", line 12, in countLOC
          comment = line.find('#')
      TypeError: expected an object with the buffer interface
  </code></pre>