title: Try/Except not running properly when opening files
body: <p>I am trying to open a file with this Try/Except block but it is going straight to Except and not opening the file.</p>
  
  <p>I've tried opening multiple different files but they are going directly to not being able to open.</p>
  
  <pre><code>import string
  
  fname = input('Enter a file name: ')
  
  try:
      fhand = open(fname)
  except:
      print('File cannot be opened:', fname)
      exit()
  
  counts = dict()
  L_N=0
  for line in fhand:
      line= line.rstrip()
      line = line.translate(line.maketrans(' ', ' ',string.punctuation))
      line = line.lower()
      words = line.split()
      L_N+=1
      for word in words:
          if word not in counts:
              counts[word]= [L_N]
          else:
              if L_N not in counts[word]:
                  counts[word].append(L_N)
  for h in range(len(counts)):
      print(counts)
  out_file = open('word_index.txt', 'w')
  out_file.write('Text file being analyzed is: '+str(fname)+ '\n\n')
  out.file_close()
  
  </code></pre>
  
  <p>I would like the output to read a specific file and count the created dictionary</p>