Sometimes you just have to take it on the chin that you will have a gain despite being 100 percent on plan. There are loads of factors outside your control that influence your weight and how much water you will hold onto. Throughout my journey I had a few occasions of unexpected gains and I can honestly say that when continuing to stick to the plan 100 percent that the following weeks losses more than made up for it, after a while this settled into a cycle and I usually had a small gai. The week before my period but a massive loss the following week. The key is to dig deep dont give up hope and keep on plan.
oh and one more thing, the scales can do mental things through the week, no weigh in is official until the offical weigh in!
good luck and keep at it x