Added code for writing nlce results to output file and other minor changes