reading document and writeing sample code