fixed file reading in remove intermediates