ADDED: Replaced atom_to_stream/2 with the more generic term_to_stream/2.