in reply to not writing to .txt file properly

Your variables $name, $country and likely $phone contain newlines. If you're reading them in from a file or from user input, you likely want to remove the newline:

... get input ... chomp $name; chomp $country; chomp $phone;

See chomp for documentation of it...

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.