added method that returns number of characters up to a certain line