Forcing focus on textbox adds a space each time

image
trying to make a code editor for fun and for some reason everytime you press enter to go to the next line, it adds 1 space to the end of the line.

Heres the code for controlling the lines:

local Entered = false
local Line = script.Parent
local UIS = game.UserInputService
Line.BackgroundTransparency = 0.5

Line.Focused:Connect(function()
	Entered = true
	print("Entered")
	Line.BackgroundTransparency = 0.5
end)

Line.FocusLost:Connect(function(EP)
	Entered = false
	print("Left")
	Line.BackgroundTransparency = 1
	
	if EP == true then
		
		if script.Parent.Parent:FindFirstChild(tostring(tonumber(script.Parent.Name)+1)) then
			script.Parent.Parent:FindFirstChild(tostring(tonumber(script.Parent.Name)+1)):CaptureFocus()
			script.Parent.Parent:FindFirstChild(tostring(tonumber(script.Parent.Name)+1)).CursorPosition = #string.split(script.Parent.Parent:FindFirstChild(tostring(tonumber(script.Parent.Name)+1)).Text, "")+1
			print("Already existed.")
		else
			local NewLine = Line:Clone()
			NewLine.Text = ""
			NewLine.CursorPosition = #string.split(NewLine.CursorPosition, "")+1
			NewLine.Name = tostring(tonumber(script.Parent.Name)+1)
			NewLine.Parent = Line.Parent
			NewLine:CaptureFocus()

			local NewNumber = script.Parent.Parent.Parent.Parent.Lines.TextLabel:Clone()
			NewNumber.Text = NewLine.Name
			NewNumber.Parent = script.Parent.Parent.Parent.Parent.Lines
		end
	end
end)