title: Searching in a .txt file (JSON format) for a particular string and then printing a specific key
body: <p>I have to take input from the user in the form of strings and then have to search for it in a .txt file which is in JSON format. If the text matches, X has to be done otherwise Y. For example if the user enters 'mac' my code should display the complete name(s) of the terms which contains the search term 'mac'. </p>
  
  <p>My JSON file has currently Big Mac as an item and when I search for 'mac' it shows nothing, whereas, it has to display me (0 Big Mac). 0 is the index number which is also required.</p>
  
  <pre><code>  if option == 's':
          if 'name' in open('data.txt').read():
              sea = input ("Type a menu item name to search for: ")
              with open ('data.txt', 'r') as data_file:
                  data = json.load(data_file)
              for line in data:
                  if sea in line:
                      print (data[index]['name'])
                  else:
                      print ('No such item exist')
          else:
              print ("The list is empty")
              main()
  </code></pre>
  
  <p>I have applied a number of solutions but none works.</p>