I can't see anything fundamentally wrong with the code. I would start looking at your hardware set up. What is PORT B connected to? Are you sure you're not drawing too much current from the PIC? That data sheet says the max current PORTA, B, and E combined can source is 200 mA. Maybe if you draw too much current, it could make the PIC not work properly. I'm not sure but that's where I'd start looking.
I could find a design fault on PCB. Even though program was written to use port B as an output, I have designed it to use as an input. I have connected 2.2k resistors between ground and port B terminals in order to input 0 at at default. As vne147 says it may take more current out from portB. After I corrected it, it worked fine. Thank you!
I have enabled LVP in configuration settings. How LVP can make an effect on that?