fixing bug where multiple blocks in the source file cause the optional argument for output file to not work. Now writing to the output only once.