document loop c