From your history it seems that you might be having internal piles.
consult surgeon and get examined.
If this problem continued, there is a chance of having anemia
due to chronic blood loss
Take more fiber containing diet.
Take plenty of water.
Take mild laxative at night.
Ok and take care.