Staying in the middle is the worst thing to do as you can get boxed in unable to sprint your way out of trouble and the riders at the back can come around the top of you and drop you. You are reasonably safe at the front until there are fairly few riders left as it will be difficult for the whole group to come around you and you can sprint your way out of trouble. You are also ok at the back as you are in the slip stream of the group and can use that to slingshot the person in front at the crucial moment and sprint for the line. What you don't want to do is stay in the middle.