Added functionality to deal with empty csv or in case that last entry is removed