Client crashes in modified PurchFormLetter class running in batch

Can someone suggest me?