Implement write + writeln functions