I am trying to use PyCharm to read a locked excel file and I used the following code: with open('abcd.xlsm', 'rb') as abcd1: excel = msoffcryptfficeFile('abcd.xlsm') excel.load_key('1234') excel.decrypt(temp) abcd1.seek(0, os.SEEK_END) while True: lines = abcd1.readline() if not lines: time.sleep(0.1) continue yield lines Can anyone tell me what's wrong with this yield function? I have been getting [SyntaxError: 'yield' outside function] I am new to python so I would appreciate some help, thank you so much! Continue reading...