> Im writing some php code to check a remote pop3 account, [ snip ] Why reinvent the wheel? Check this out : http://www.thewebmasters.net/php/class.POP3.phps If you still plan to use your own function, I would suggest this snippet (from the above class) : $count = 0; $MsgArray = array(); $line = fgets($fp,$buffer); while ( !ereg("^\.\r\n",$line)) { $MsgArray[$count] = $line; $count++; $line = fgets($fp,$buffer); if(empty($line)) { break; } } hth --Burhan