getnext and writeout are perfect