added option for intermediate output file