Currently working on Solaris 

I need to search for a specific string in a text file and, if found, join it to the previous line. For example:

```
if logical condition
then
i = i + 1

```

Would become

```
if logical condition then
i = i + 1.

```

I'm sure I can do this with awk using a hold space of some sort but my awk skills are a little rusty.

---

Addendum: Apologies, I should have been more specific. The match is triggered by the appearance of the string "then". I have no knowledge of the contents of the previous line - it could be anything. Whatever it is I need to concatenate the "then" to it.