move io functions to io.h