Fixed a bug where garbage was dumped to file instead of type-specific.