```
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

stringOfWords = "this is a sentance I want to send word by word"
listOfWords = stringOfWords.split(" ")

driver = webdriver.Edge('C:/Users/Andrej/OneDrive - UKIM, FINKI/Kodovi/Python/msedgedriver.exe')
user = '*myusername*'
pw = '*mypassword*' 

driver.get("https://facebook.com")
sleep(2)
driver.find_element_by_xpath("//input[@name=\"email\"]").send_keys(user)
driver.find_element_by_xpath("//input[@name=\"pass\"]").send_keys(pw)
sleep(1)
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div/div/div/div[2]/form/table/tbody/tr[2]/td[3]/label/input').click()
sleep(6)
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/div/div/div/div[2]/div[2]/div[2]/div/a').click()
sleep(1)
driver.find_element_by_xpath("//span[.='*the name of the person I want to send it to*']").click()

#everything works fine until here
msgbox = driver.find_element_by_xpath('/html/body/div[1]/div[7]/div[1]/div/div/div[4]/div/div[1]/div/div/div/div/div/div[1]/div/div[2]/div[4]/div/div/div/span/div/div/div[2]/div/div/div/div')

for word in listOfWords:
    if word != ' ':
        msgbox.send_keys(word)
        sleep(2)
        msgbox.send_keys(Keys.RETURN)
        sleep(2)

```

It works fine until the second word. It sends the first one but after the second one it crashes and gives me a "StaleElementReferenceException".

I know I'm doing something very obviously wrong but I can't find a solution anywhere

(I'm using Edge Chromium as a browser but I get the same results on Chrome)