write to file, streamline I/O