python - find occurrences of strings from a reference file within an input file
<p>I have two files. Call one file as a reference file. This file contains a list of strings each on a separate line. The other file is an input file. It also has strings on on each line. 
I want to find the occurrence of each string from the reference file within the input file. This is my code</p>

<pre><code>def count_line_occurrences(ref_list,input_list):
  line_counter = {}
  # Initialization
  for ref_line in ref_list:
    ref_line = ref_line.rstrip()
    line_counter[ref_line] = 0
  for input_line in input_list:
      input_line = input_line.rstrip()

  for ref_line in ref_list:
    #print ref_line
    for input_line in input_list:
      #print input_line
      if str(input_line).find(str(ref_line)) != -1:
        print 'found ' + ref_line
        line_counter[ref_line] += 1
  return line_counter
</code></pre>

<p>However it is not working. 
Note - This is not a HW problem. But this is a part of a bigger task. Also, strangely, I have implemented this part in Perl and it is working fine. I want to shift the project to Python and I am having issues here. Thanks in advance for the help.</p>
