We have a large tsv file where the data for a single row are splitted into different rows with new line delimiter.

We need to join them together based on the tab counts.

For eg: If suppose the total tab count for a single row is 995 , the data is split in between as follows,

```
Row Number  Tab Count
Row 1       660
Row 2       0
Row 3       300         
Row 5       20
Row 6       15
Total       995

```

N.B The above row split is not consitent and varies.

I want to add the tab counts and once we get 995 as total , need to join the data from different rows into one single row.

We have the below command to join the lines based on new line delimiter.

```
paste -sd '\n' inputfile > output file

```

I want to know,

1. If we can get the tab counts for different rows
2. Add the tab counts to get sum of 995
3. Once the sum is achieved , whichever tab counts were added from those rows , need to be joined into one single row.

Please let me know if this can be achieved using shell script.

Thanks.!