Added error handling for all system calls
Wrote program comment