Concatenate two lines if they are not empty

Viewed 129

I want to combine 2 lines of text into one, but only when they are both not empty lines. For example:

1:1 Bob drives his car.
1:2 Bob and his wife are going on a trip. 
They will have an awesome time on the beach.

I want to put them into a dictionary like this:

dict[1:1] gives me "Bob drives his car."
and dict[1:2] must give me "Bob and his wife are going on a trip.They will have an awesome time on the beach."

I know how to fix the fist one (dict[1:1]), but I have no idea how I can take the two sentences together.

Or is there an option that if a sentence is followed by another one you can put them on one line? This is just an example in reality , the file contains 100000 lines.

3 Answers
Related