I'm trying to write a small function (if one doesn't already exist) to break up long lines of text into CRLF seperated chunks.

Example:
The inputted text is "Hello this is a lot of text! Can you see how much text it is? Imagine trying to make this all one line."

The function would notice that it's longer than 30 characters, so it needs to break it up to approx 30 letters per line...

"Hello this is a lot of text! "
"Can you see how much te"
"xt it is? Imagine trying to "
"make this all one line."

However, obviously that's no good..

So, basically, I need a function which would notice that it's the middle of the word and adjust accordingly. My code so far is, frankly, a horrible mess so I'll spare you the pain of having to witness my ineptitude.

Any suggestions?

Thank you.