read a file line by line

Hello there,
I have a script that I would like to read a file line by line and launch a function with the entire line as a parameter. I wrote something that reads the file word after word. Can you help me correct it?
Thanks in advance
Santiago

~$ cat test
myfunction() {
    # to make it simple, I just echo the argument
    echo "$1"
}
for line in $(cat "$1"); do
    myfunction $line
done
~$ cat file
Santiago Diez
Something else
Anything   weird
~$ ./test file
Santiago
Diez
Something
else
Anything
weird

You don't need a function:

while IFS= read -r; do
  yourfunction "$REPLY"
done<filename

Thanks radoulov,
I also wrote this solution thanks to this post found in the forum:

while read line; do
    myfunction "$line"
done < "$1"

You've removed some parts of my post, so beware of the following:

$ cat -te file
   $
  Santiago Diez  $
Some\thing else$
Anything   weird$
$
$ while read line; do
>   printf '|%s|\n' "$line"
> done<file
||
|Santiago Diez|
|Something else|
|Anything   weird|
||
$ while IFS= read -r line; do
>   printf '|%s|\n' "$line"
> done<file
|   |
|  Santiago Diez  |
|Some\thing else|
|Anything   weird|
||

Hum, yes.
Actually, I'm pretty newbee in shell script. Altough I've been working for several months with it, I never had any proper lecture about that.
So I just took out what I couldn't understand and noticed that it was still working... Until you mentioned the limits.
So if you have time, could you help me on that:
1) I found no help about read's switch r.
2) How can you write IFS= just before read, even without semi-colon to separate the commands? What's the purpose? Does it modify the value of IFS forever or just in the loop?
Thanks in advance
Santiago

From the bash builtin help:

$ help read
read: read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
...
If the -r option is given, this signifies `raw' input, and
    backslash escaping is disabled.

It's set only for the read call. Consider the following:

while IFS= read; do
  printf '\nread with empty IFS: |%s|\n' "$REPLY"
  read inside<<<"$REPLY"
  printf '\nread inside the loop: |%s|\n\n' "$inside"  
  printf "... so the current IFS is:\n"  
  od -bc<<<"$IFS" 
done<<<"   _x_   "

The output is:

read with empty IFS: |   _x_   |

read inside the loop: |_x_|

... so the current IFS is:
0000000 040 011 012 012
             \t  \n  \n
0000004

The combination space, tab and newline is the default value.

neat and clear,
thanks a lot

Actually, I didn't know the existence of function help:

~$ man read
No manual entry for read

It's a shell builtin, not an external command.
You will find in it in the bash(or whatever shell supporting that builtin you're using) man pages in the SHELL BUILTIN COMMANDS section.

Hi,

under bash the is the "help" command for infos on build-in functions. So

help read

should do the trick.

HTH Chris