Text in buffer: "123\n" Read: "123" Text in buffer: "\n" Read: exception, expecting number for "\n" Changing your readf format specifier to include the new line should work. https://dlang.org/phobos/std_stdio.html#.File.readf