title: None type object is not iterable
body: <p>Before someone tells me to search the web some more, I have searched for over an hour already.</p>
  
  <p>So my assignment requires me to use an imported module that contains a safeOpen function that opens a file for the main module, selectiveFileCopy. But when I call the safeOpen function, it says that the file I am trying to open is a None type, and is therefore not iterable. I'm not sure why that is.</p>
  
  <p>Here's some code:</p>
  
  <pre><code>def safeOpen(prompt, openMode, errorMessage ):
     while True:
        try:
           open(input(prompt),openMode)
           return 
        except IOError:
           return(errorMessage)
  
  def selectivelyCopy(inputFile,outputFile,predicate):
     linesCopied = 0
     for line in inputFile:
        outputFile.write(inputFile.predicate)
        if predicate == True:
           linesCopied+=1
     return linesCopied
  
  
  inputFile = fileutility.safeOpen("Input file name: ",  "r", "  Can't find that file")
  outputFile = fileutility.safeOpen("Output file name: ", "w", "  Can't create that file")
  predicate = eval(input("Function to use as a predicate: "))   
  print(type(inputFile)) 
  print("Lines copied =",selectivelyCopy(inputFile,outputFile,predicate))
  </code></pre>