testing loop, output into file