using file handles and in place array rotation