Fixed padding error in writing