Hello Mus.me,
Please tell us which PIC you are using, as each is a little different, so WE may look into it's data sheet. Your code looks like it will work BUT the unknown is if your PIC has analog stuff on portB, which you have not disabled.