how to run a code once in the void loop?

See reply #1.
Or put the print in setup, where it will be executed just once per reset.