first check, than write.. - caused a repeat of the last character if newline is found (and broke my testbench...)