loop before using fileAPI