DNN-4756

added code from Je on the forums and updated it slightly for line termination errors.