Fix restore cursor position

The position of the cursor was not correctly perform indeed  the "\n" character was not count as a character. The restore position was not able the retrieve the good position because it didn't search at the good place.