added necessary headers for read,write and perror
added p_ to names of pointers