Use write() instead of << for binary files