Fixed the HTTPError handling for the last fucking time + other stuff...

So I wanted to modularize the program further, so I put most of the code from beneath if __name__ == "__main__": and put it into functions. I also added a check to make sure that subreddits are valid.