Fixed error with TextWriter if buttons were pressed before the cursor
index was able to update and allow for text input properly.