Hello, i'm creating an iTunes remote for the psp the app connects to my computer via Wirless lan which i have created a server for.

Its all working well but its just creating the GUI interface etc..

My issue is my screen dosent clear and it should look like this

===============
| PSP SCREEN |
|Recived: |
|Sent: |
|Now Playing: |
===============

However for some reason its doing this

================================
| PSP SCREEN |
|Recived: |
|Sent: |
|Now Playing:NowPlaying:NowPlayingNowPl|
================================

My code:

Code:
System.usbDiskModeActivate()  -- Enables USB Mode (Remove when completed)

-- Start of color list
red = Color.new(255,0,0)
white = Color.new(255,255,255) 
green = Color.new(0,255,0)
grg = Color.new(0,120,255)
playing = "N/A"
x = 62
y = 18
-- End of color list
function keepDraw()  -- Handle Drawing (Bit like garrysmod lua...)
	screen:fillRect(12,10,456,255,white)
	screen:fillRect(15,12,445,30,red)
	screen:fillRect(15,50,445,60,green)
	screen:fillRect(15,120,445,12,grg)
	screen:print(85, 22, "Dys0n's iTunes PSP Remote Version 0.2", green)
	screen:print(18, 52, "Server Input:", grg)
	screen:print(18, 122, ""..playing, white) -- Playing should be refreshed everytime keepDraw is run.
	screen:clear()
end

function graphicsPrintln(text)
	screen:print(y, x, text, white)
	x = x + 8
end
keepDraw()
Wlan.init()
configs = Wlan.getConnectionConfigs()
Wlan.useConnectionConfig(1)
serverSocket = Socket.createServerSocket(80)
while true do
	ipAddress = Wlan.getIPAddress()
	if ipAddress then break end
	System.sleep(100)
end
socket, error = Socket.connect("192.168.1.102", 12345)
while not socket:isConnected() do System.sleep(100) end
screen:print(y, x, "Connected to " .. tostring(socket), grg);
pad = Controls.read() 
requestCount = 0
header = ""
headerFinished = false
while true do
keepDraw()
screen:clear()
		buffer = socket:recv();
	if string.len(buffer) > 0 then 
		if headerFinished then
			graphicsPrint(buffer)
		else
			header = header .. buffer
			startIndex, endIndex = string.find(header, "\r\n")
			if endIndex then
				if string.find(string.sub(header, endIndex), "Now Playing:") then
					playing = ""
					playing = string.sub(header, endIndex)
					screen:fillRect(15,120,445,12,grg)
					screen:print(18, 122, ""..playing, white)
					screen:clear()
				else
					graphicsPrintln(string.sub(header, endIndex))
				end
			end
		end
	end
	
	-- check for incoming requests
	incomingSocket = serverSocket:accept()
	if incomingSocket then
		requestCount = requestCount + 1
		incomingSocket:close()
	end
	if Controls.read():cross() then
		bytesSent = socket:send("ITUNES_PLAY\r\n");
		graphicsPrintln("Commnad: PLAY\r\n")
		System.sleep(250)
	end
	if Controls.read():square() then
		bytesSent = socket:send("ITUNES_STOP\r\n");
		graphicsPrintln("Commnad: STOP\r\n")
		System.sleep(250)
	end
	if Controls.read():start() then break end
end

Please help