Prevent endless loop in writeLiteral()

writeLiteral() was stuck in an endless loop
logging this message until the HDD was full:

PHP ERROR: feof() expects parameter 1 to be resource, integer given [pid 24223 on line 106 of "/usr/share/pear/Horde/Imap/Client/Socket/Connection/Socket.php"]
PHP ERROR: fread() expects parameter 1 to be resource, integer given [pid 24223 on line 107 of "/usr/share/pear/Horde/Imap/Client/Socket/Connection/Socket.php"]

Prevent it by checking the return value of fread().

While we are at it, check the return value of rewind(), too.

Signed-off-by: Michael M Slusarz <slusarz@horde.org>
coding standard tweaks
[mms] Better error checking when writing data to the server (Bug #13187; Thomas Jarosch <thomas.jarosch@intra2net.com>).