When I run that code nothing stops the sprite from leaving the screen. Are you sure you copied the code exactly? It seems like the if(sf::Keyboard::isKeyPressed... blocks should be contained inside the if(sprite.getPosition()... block, or else the velocityX = 0; statement doesn't actually stop it from moving.
But that aside, the problem is fairly simple. You just need to think about what's going on at the bottom of your code some more. At the moment, when the bullet is at either edge of the screen, you tell it to not move at all (velocityX = 0;). What you actually want is to let it move in one direction only. So what you probably should do is something like this:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
velocityX = movespeed;
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
velocityX = -movespeed;
if(sprite.getPosition().x + 9 > 320 && velocityX > 0) //if on right edge and trying to move right, don't let it move
velocityX = 0;
if(sprite.getPosition().x < 0 && velocityX < 0) //if on left edge and trying to move left, don't let it move
velocityX = 0;
//now that we've done that check, actually move it
sprite.move(velocityX,0);