Question: why is fopen not working?
Answer: Most common issues are: file does not exists (or just incorrect path provided?), there is not enough permissions to read this file. Change that second line to: $fh = fopen("/my/path/to/file. txt", "r") or die($php_errormsg);