Script that gets the first tag of post and query all other posts with the same tag

the query expects the tag slug, not the tag name:

$tag = $tag->slug . ' ';

and there is an error in the query syntax; corrected:

query_posts('tag='.$tag.'&posts_per_page=-1');

edit:
full code rearranged:

$posttags = get_the_tags(); 
if ($posttags) {   
    foreach($posttags as $tag) {     
        $tag = $tag->slug;  break;  
    } 
query_posts('tag='.$tag.'&posts_per_page=-1');      
    while (have_posts()) : the_post(); ?> 

    <p><a href="https://wordpress.stackexchange.com/questions/27106/<?php the_permalink(); ?>"><?php the_title(); ?></a></p>

    <?php endwhile;  
    wp_reset_query();  
}