title: urllib downloading contents of an online directory
body: <p>I'm trying to make a program that will open a directory, then use regular expressions to get the names of powerpoints and then create files locally and copy their content. When I run this it appears to work, however when I actually try to open the files they keep saying the version is wrong.</p>
  
  <pre><code>from urllib.request import urlopen
  import re
  
  urlpath = urlopen('http://www.divms.uiowa.edu/~jni/courses/ProgrammignInCobol/presentation/')
  string = urlpath.read().decode('utf-8')
  
  pattern = re.compile('ch[0-9]*.ppt') #the pattern actually creates duplicates in the list
  
  filelist = pattern.findall(string)
  print(filelist)
  
  for filename in filelist:
      remotefile = urlopen('http://www.divms.uiowa.edu/~jni/courses/ProgrammignInCobol/presentation/' + filename)
      localfile = open(filename,'wb')
      localfile.write(remotefile.read())
      localfile.close()
      remotefile.close()
  </code></pre>