Read record from the text file & assign those values to variables in the script

For eg: I have sample.txt file with 4 rows of record like:

user1|password1
user2|password2
user3|password3
user4|password4

The username and password is sepsrated by '|'

I want to get the 1st row value from the file and assign it to two different variables(username and password)
in my script. Please guide me how to proceed.

Thanks,
priya

[root@node2 ~]# cat get 
while IFS='|' read name pass; do
      n_name=${name}
      n_pass=${pass}
      echo ${n_name} ${n_pass}
done < $1
[root@node2 ~]# cat data 
user1|password1
user2|password2
user3|password3
user4|password4
[root@node2 ~]# bash get data 
user1 password1
user2 password2
user3 password3
user4 password4