Well, I'm not quite sure what you mean by acentuation, maybe I'm just stupid. But...as far as the white space goes...
$file_contents = str_replace(" ", "", $file_contents);
Something like that is how you get rid of spaces. You can take it from there.