As this is linux, could it be a permissions problem on the folder where you are trying to write the file?
Coming from a Windows background, this sort of thing drove me nuts, so, although not advisable in the real world, I granted everybody read/write permissions on the folder I was using whilst showing the concept.