Programmatically Flush WordPress Permalink Rewrite Rules

When adding rewrite rules with add_rewrite_rule add this to the file you are editing and avoid clicking save on the permalink settings page.