Use $in
Refactor: Split write() into abstract and concrete parts
Implement sequential writing