Copyright infringement requires that you actually copy elements from an earlier work produced by a different author. If you created a similar, or even identical, work independently, it is not copyright infringement.
When considering whether or not infringement has occurred, the court is likely to consider whether the defendant could reasonably have had access to the plaintiff's work. If the court finds that they could have, then the defendant would be required to produce evidence of original authorship.
Consider the My Sweet Lord/He So Fine case, where the court found the defendant had subconsciously copied the plaintiff's song. Had Harrison been able to produce evidence of original authorship, the judgment could have been different.
In your example, it is unlikely that an suit in copyright infringement could be decided against you, as you've stated the text is generated randomly. However, more evidence of this randomness might be required to support your case.
Of course, whether a computer or automated process can produce works independently is still questionable; I'm not aware of cases that have tried this. The US Copyright Office has said that Works produced by mechanical processes or random selection without any contribution by a human author are not registrable. Of course, whether this has a bearing on your particular scenario is undecided, and I'm not sure how it would be decided.
It is almost certain that the worst case outcome would be an injunction requiring you to cease publicising the product, or perform reasonable checks prior to publication to ensure that the product of your program infringes on works; it would be unlikely that you would have costs ordered against you, especially if the program is truly random, and the random text was given as much, or more, publicity than the coherent text.