Fix bug in creating bed file