It seems that there is a race condition in this code.
If I am correct you use the file:open to create a file when it does not exist, and then append some data in it.
It seems that you get the IoDevice before the file is ready to be written in the underlying system, and as you use a different access type (ignoring the file handle you've just created) the append fails.
If you execute the 2 lines in the shell, in 2 separate commands, you will see that it works.
A better code should be:
append(Filename,Data) ->
case file:read_file_info(Filename) of
{error, enoent} ->
file:write_file(Filename, Data); % create the file and write
{ok, _FileInfo} ->
file:write_file(Filename, Data,[append]) % append data to existing file
end.