diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 4cea9cd..d8a8f69 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -708,19 +708,21 @@
 		{

 			return FALSE;

 		}

-	

+		

+		if ( ! $data = file_get_contents($file))

+		{

+			return FALSE;

+		}

+		

 		if ( ! $fp = @fopen($file, 'r+b'))

 		{

 			return FALSE;

 		}

-			

-		flock($fp, LOCK_EX);

 

-		$data = fread($fp, filesize($file));

-		

 		$CI =& get_instance();	

 		$data = $CI->input->xss_clean($data);

-

+		

+		flock($fp, LOCK_EX);

 		fwrite($fp, $data);

 		flock($fp, LOCK_UN);

 		fclose($fp);