That would be the hard way to do it. What you want is pretty common, so WordPress built it in. What you need to do is go to the settings area and click on "discussion". Now uncheck the third option which should be "Allow people to post comments on new articles".
This gets you half way there. New posts won't have a comment section, but you will still need to tell the older posts and pages to not allow comments. To do this, go to the posts page, and click the checkmark for all the posts. (the one at the top selects all of them at once instead of you having to check each one.) Then, go up to the box at top and select "edit" then you have to click the "apply" button just an inch to the right. This will open up a box which all kinds of things you can do to the selected posts en mass. Just uncheck the "allow comments" box and update on the bottom right and you're all set. If you don't want pages to have comments either, go the pages list and do the same thing. Have fun!