ASX 200 posts fourth monthly gain despite Friday profit-taking