Fixed cursor positioning when moving past end of lines