writing cam to file