formatted the main function a bit. Got rid of the warning I was getting. Also made it so that it actuallt allocates memory for writeto