read file and write contents