Modified writing into the file for better understanding.